demo-copy-fs
v1.0.1
Published
```js const program=require("commander"); const inquirer=require("inquirer"); const fs=require("fs"); program.command("create") .description("创建") .action((dir)=>{ inquirer.prompt([{ type:"checkbox", name:"list",
Downloads
3
Readme
const program=require("commander");
const inquirer=require("inquirer");
const fs=require("fs");
program.command("create")
.description("创建")
.action((dir)=>{
inquirer.prompt([{
type:"checkbox",
name:"list",
message:"请选择你要合并的文件",
choices:["a.js","b.js","c.js"]
}]).then(res=>{
const {list}=res;
inquirer.prompt([{
type:"input",
name:"filename",
message:"请输入你要创建的文件名?",
validate:(val)=>{
if(val.indexOf(".")>-1){
return true
}
}
}]).then(res=>{
let str="";
str+=list.map(item=>{
return fs.readFileSync(item,"utf-8")
})
fs.writeFileSync(res.filename,str)
})
})
})
program.version("1.0.0");
program.parse(process.argv);