UNPKG

@mhy/config

Version:

> This documentation is not complete. It's in progress and it's a BETA version. Use the tool at your own risk.

61 lines (45 loc) 1.6 kB
"use strict"; var _path = _interopRequireDefault(require("path")); var _dist = _interopRequireDefault(require("@mhy/process/dist")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } const { moduleHome } = require('../../index'); const CmdTscCLI = ['node', require.resolve('typescript/lib/tsc.js'), process.MHY_ENV === 'ui' ? '-w' : '', '--project', _path.default.resolve(process.cwd(), 'tsconfig.json')]; class Tsc extends _dist.default { constructor(args) { const { args: [defaultAction = 'start'], flags } = args; super(args); _defineProperty(this, "onStart", ({ name }) => { // Just initiate tsconfig.json creation require(_path.default.resolve(moduleHome, 'typescript/index.js')); // Ensure file is being written setTimeout(() => this.spawn(name, CmdTscCLI), 200); }); _defineProperty(this, "onRestart", async () => { await this.kill('start'); this.run('start'); }); _defineProperty(this, "actions", [{ name: 'start', enabled: true, onRun: this.onStart }, { name: 'restart', label: 'Restart', shortcut: 'r', enabled: true, onRun: this.onRestart }]); this.run(defaultAction, { flags }); } } _defineProperty(Tsc, "isEnabled", true); module.exports.default = () => Tsc;