bunny-cli/bin/index.js

32 lines
906 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
const { program } = require('commander'); // 命令行提示工具
const path = require('path'); // 引入操作路径
const { CommandLogHelp, CommandLogStart } = require('./command-log');
const { fileIsExist, createProject, downloadProject } = require('./utils');
// 首行显示
CommandLogStart();
// 创建项目命令
program
.command('create <app-name>')
.description('创建一个新项目')
.action(async function (name) {
// 创建项目-创建一个名字为name的项目如果存在是否覆盖
const targetPath = path.join(process.cwd(), name);
// 文件夹下是否有这个名字
const result = await fileIsExist(targetPath, name);
if (result) {
// 新建项目
const key = await createProject();
// clone项目
downloadProject(targetPath, key, name);
}
});
// 给help信息添加提示
CommandLogHelp();
program.parse(process.argv);