UNPKG

@cliz/gpm

Version:
40 lines (39 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const cli_1 = require("@cliz/cli"); const core_1 = require("../core"); exports.default = (0, cli_1.defineSubCommand)((createCommand) => { return createCommand('Project Dev') .option('-e, --exec <command>', 'Custom dev command') .option('-w, --watch [watchPath]', 'Enable live reload, and set watch path, default: current dir') .option('-c, --context <context>', 'Command context') .action(async (action) => { var _a; const options = action.options; const command = typeof options.command == 'boolean' ? '' : options.exec; const watchPath = typeof options.watch === 'boolean' ? process.cwd() : options.watch || process.cwd(); const context = (_a = options.context) !== null && _a !== void 0 ? _a : process.cwd(); // @TODO <> 必须参数,好像失效了??? if (typeof options.context === 'boolean') { throw new Error(`context(-c, --context <context>) is required`); } await core_1.default.prepare(); await core_1.default.devtools.prepare(); if (options.watch) { if (!command) { throw new Error(`command(--exec <command>) is required`); } return await core_1.default.devtools.watch({ command, path: watchPath, context, }); } return await core_1.default.devtools.dev({ command, context, }); }); });