UNPKG

@cliz/gpm

Version:
46 lines (45 loc) 1.82 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, { api }) => { return createCommand('Project Watch') .option('-e, --exec <command>', 'Custom watch command') .option('-c, --context <context>', 'Project path') .option('-p, --path <path>', 'Custom watch path') .option('-i, --ignore <path>', 'Custom ignore path, string or regexp') .action(async (action) => { var _a; const options = action.options; const command = (_a = options.command) !== null && _a !== void 0 ? _a : options.exec; const path = options.path; const ignore = []; const context = options === null || options === void 0 ? void 0 : options.context; if (options.ignore) { ignore.push(options.ignore); } const ignoreFilePath = api.path.join(process.cwd(), '.gpmignore'); if (await api.fs.exist(ignoreFilePath)) { const text = await api.fs.readFile(ignoreFilePath, 'utf8'); const lines = text.split(/\r?\n/); const cwd = process.cwd(); lines.forEach((line) => { if (line) { // @TODO const fullpath = api.path.join(cwd, line); ignore.push(fullpath); // ignore.push(line); // ignore.push(new RegExp(`^${line}$`)); } }); } await core_1.default.prepare(); await core_1.default.devtools.prepare(); await core_1.default.devtools.watch({ command, path, ignore, context, }); }); });