1 | "use strict";
|
2 |
|
3 | var _chalk = _interopRequireDefault(require("chalk"));
|
4 |
|
5 | var _shelljs = require("shelljs");
|
6 |
|
7 | var _consoleApplication = require("../Commons/consoleApplication");
|
8 |
|
9 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10 |
|
11 | _shelljs.config.verbose = true;
|
12 | (0, _consoleApplication.runConsoleApplication)(async context => {
|
13 | const watch = [...process.argv].includes("--watch") || [...process.argv].includes("-w");
|
14 |
|
15 | if (watch) {
|
16 |
|
17 | (0, _shelljs.mkdir)("Generator/dist/Generator");
|
18 | (0, _shelljs.cp)("Generator/eslintrc-generated-code.json", "Generator/dist/Generator");
|
19 | execAsyncWithPrefix('babel --watch --extensions ".js,.jsx,.ts,.tsx" Engine/src --out-dir Generator/dist/Engine/src --delete-dir-on-start', "Babel");
|
20 | execAsyncWithPrefix('babel --watch --extensions ".js,.jsx,.ts,.tsx" Generator/src --out-dir Generator/dist/Generator/src --delete-dir-on-start --copy-files', "Babel");
|
21 | await context.waitForExit();
|
22 | } else {
|
23 | (0, _shelljs.exec)('babel --extensions ".js,.jsx,.ts,.tsx" Engine/src --out-dir Generator/dist/Engine/src');
|
24 | (0, _shelljs.exec)('babel --extensions ".js,.jsx,.ts,.tsx" Generator/src --out-dir Generator/dist/Generator/src --delete-dir-on-start --copy-files');
|
25 | (0, _shelljs.cp)("Generator/eslintrc-generated-code.json", "Generator/dist/Generator");
|
26 | }
|
27 | });
|
28 |
|
29 | function execAsyncWithPrefix(command, prefix) {
|
30 | process.stdout.write(_chalk.default.gray(`[${prefix}] `));
|
31 | process.stdout.write(command + "\n");
|
32 | const childProcess = (0, _shelljs.exec)(command, {
|
33 | async: true,
|
34 | silent: true
|
35 | });
|
36 |
|
37 | if ("pid" in childProcess) {
|
38 | childProcess.stdout.on("data", data => {
|
39 | process.stdout.write(_chalk.default.gray(`[${prefix}] `));
|
40 | process.stdout.write(data);
|
41 | });
|
42 | childProcess.stderr.on("data", data => {
|
43 | process.stdout.write(_chalk.default.gray(`[${prefix}] `));
|
44 | process.stdout.write(data);
|
45 | });
|
46 | return childProcess;
|
47 | } else {
|
48 | throw new Error("InvalidProgramState");
|
49 | }
|
50 | }
|
51 |
|
\ | No newline at end of file |