-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.js
More file actions
29 lines (29 loc) · 900 Bytes
/
Copy pathdelete.js
File metadata and controls
29 lines (29 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const co = require('co');
const prompt = require('co-prompt');
const config = require('../templates');
const chalk = require('chalk');
const fs = require('fs');
const path = require("path");
const filePath = path.resolve(__dirname,"..","templates.json");
module.exports = () => {
co(function * () {
// 接收用户输入的参数
let tplName = yield prompt('模板名字: ');
// 删除对应的模板
if(config.tpl[tplName]){
config.tpl[tplName] = undefined;
}else{
console.log(chalk.red('模板不存在'));
process.exit();
}
// 写入文件
fs.writeFile(filePath,JSON.stringify(config),'utf-8',(err) => {
if(err){
console.log(err);
}
console.log(chalk.green('删除成功\n'));
process.exit();
});
});
};