flow-build
Version:
58 lines (46 loc) • 1.27 kB
Plain Text
;
const path = require("path");
const { existsSync } = require("fs-extra");
let env, config;
let argv = require("yargs")
// .version(require('../package').version)
.usage("Usage: $0 <command> [options]")
.command("start", "start the application in development mode", () => {
env = "start";
})
.command("build", "compiles the application for production deployment", ()=> {
env = "build";
})
.option("c", {
alias : "config-file",
default: "./flow.config.js",
describe: "Path to flow.js config file (default: flow.config.js)",
type: "string"
})
.help("help")
.alias("help", "h")
.version()
.alias("version", "v")
.default("v", require("../package").version)
.argv;
/**
* 获取配置文件路径,默认为当前项目下的flow.config.js
*/
let ConfigFilePath = path.join(process.cwd(), argv["config-file"]);
/**
* 检测配置文件是否存在
*/
if (!existsSync(ConfigFilePath)) {
config = {};
} else {
config = require(ConfigFilePath);
}
let Builder = require("../src/index");
if (env=="start") {
config.env = "dev";
} else {
config.env = "prod";
}
let builder = new Builder(config);
builder.run();