uni-run 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js
CHANGED
|
@@ -42,6 +42,7 @@ const argHelper_1 = require("./argHelper");
|
|
|
42
42
|
const scriptExecutors_1 = __importDefault(require("./scriptExecutors"));
|
|
43
43
|
const checkRuntime_1 = __importDefault(require("./scriptExecutors/checkRuntime"));
|
|
44
44
|
const getUserExecutors_1 = __importDefault(require("./helpers/getUserExecutors"));
|
|
45
|
+
const colors_1 = __importDefault(require("./lib/colors"));
|
|
45
46
|
arg.app.on((_a, flags_1) => __awaiter(void 0, [_a, flags_1], void 0, function* ([script, listArs, trailingArgs], flags) {
|
|
46
47
|
var _b;
|
|
47
48
|
const userExecutors = (0, getUserExecutors_1.default)(flags.cwd);
|
|
@@ -52,7 +53,7 @@ arg.app.on((_a, flags_1) => __awaiter(void 0, [_a, flags_1], void 0, function* (
|
|
|
52
53
|
];
|
|
53
54
|
const scriptExecutor = totalExecutors.find((executor) => executor.exts.includes(script.split('.').pop()));
|
|
54
55
|
if (!scriptExecutor) {
|
|
55
|
-
console.
|
|
56
|
+
console.error('Unsupported script:', script);
|
|
56
57
|
return console.log('You may try "run exec YOUR_BIN script.ext -- --flags"');
|
|
57
58
|
}
|
|
58
59
|
const executionOptions = (0, argHelper_1.mapFlagsToOptions)(flags);
|
|
@@ -71,14 +72,8 @@ arg.list.on(() => {
|
|
|
71
72
|
...(Array.isArray(userExecutors) ? userExecutors : []),
|
|
72
73
|
...scriptExecutors_1.default,
|
|
73
74
|
];
|
|
74
|
-
console.log('Supported scripts:');
|
|
75
|
-
totalExecutors
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
return -1;
|
|
79
|
-
if (a.name > b.name)
|
|
80
|
-
return 1;
|
|
81
|
-
return 0;
|
|
82
|
-
})
|
|
83
|
-
.forEach(({ name }) => console.log(`- ${name}`));
|
|
75
|
+
console.log(colors_1.default.bold('Supported scripts:'));
|
|
76
|
+
totalExecutors.forEach(({ name, exts }) => {
|
|
77
|
+
console.log(`- ${colors_1.default.magenta(name)}`, `[${exts.map((e) => '.' + colors_1.default.green(e)).join(', ')}]`);
|
|
78
|
+
});
|
|
84
79
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RuntimeOptions } from './types.t';
|
|
2
|
-
export default function (runtime: RuntimeOptions):
|
|
2
|
+
export default function (runtime: RuntimeOptions): void;
|
|
@@ -4,39 +4,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
+
const colors_1 = __importDefault(require("../lib/colors"));
|
|
7
8
|
const confirm_1 = __importDefault(require("@inquirer/confirm"));
|
|
8
9
|
const cross_spawn_1 = require("cross-spawn");
|
|
9
10
|
function default_1(runtime) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return canBeInstalled(runtime.install);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function isInstalled(commands) {
|
|
16
|
-
if (!(commands === null || commands === void 0 ? void 0 : commands.length))
|
|
17
|
-
return true;
|
|
18
|
-
const [command, ...args] = commands;
|
|
19
|
-
const result = (0, cross_spawn_1.sync)(command, args, {
|
|
20
|
-
stdio: 'ignore',
|
|
21
|
-
});
|
|
22
|
-
if (result.status === 1)
|
|
23
|
-
return false;
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
function renderHowToInstall(name, hints) {
|
|
27
|
-
if (!(hints === null || hints === void 0 ? void 0 : hints.length))
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
if (!((_a = runtime.isInstalled) === null || _a === void 0 ? void 0 : _a.length))
|
|
28
13
|
return;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
const [command, ...args] = runtime.isInstalled;
|
|
15
|
+
const result = (0, cross_spawn_1.sync)(command, args, { stdio: 'ignore' });
|
|
16
|
+
if (result.status === 0)
|
|
17
|
+
return;
|
|
18
|
+
if ((_b = runtime.installHints) === null || _b === void 0 ? void 0 : _b.length) {
|
|
19
|
+
console.error(`${runtime.run[0]} is not installed.`);
|
|
20
|
+
console.log(colors_1.default.bold('How to install:'));
|
|
21
|
+
runtime.installHints.forEach((hint) => console.log(hint));
|
|
22
|
+
}
|
|
23
|
+
if ((_c = runtime.install) === null || _c === void 0 ? void 0 : _c.length) {
|
|
24
|
+
(0, confirm_1.default)({ message: 'Do you want to install it?' }).then((ans) => {
|
|
25
|
+
if (!ans)
|
|
26
|
+
return;
|
|
27
|
+
const [command, ...args] = runtime.install;
|
|
28
|
+
(0, cross_spawn_1.sync)(command, args, { stdio: 'inherit' });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
42
31
|
}
|