uni-run 1.0.3 → 1.0.5
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/arg-helper.d.ts +25 -2
- package/dist/arg-helper.js +7 -2
- package/dist/arg.d.ts +17 -1
- package/dist/arg.js +2 -2
- package/dist/builtin-bin/Executor.d.ts +14 -15
- package/dist/builtin-bin/Executor.js +29 -11
- package/dist/builtin-bin/index.js +50 -59
- package/dist/execution/index.d.ts +3 -14
- package/dist/execution/index.js +15 -2
- package/dist/execution/watcher.js +1 -1
- package/dist/index.js +8 -8
- package/package.json +6 -5
package/dist/arg-helper.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import NoArg from 'noarg';
|
|
2
2
|
import type { app } from './arg';
|
|
3
|
-
import { ExecuteOptions } from './execution';
|
|
4
3
|
import Executor from './builtin-bin/Executor';
|
|
5
4
|
export declare const executionConfig: {
|
|
6
5
|
readonly flags: {
|
|
@@ -29,6 +28,9 @@ export declare const executionConfig: {
|
|
|
29
28
|
default: false;
|
|
30
29
|
description: "Show the execution time";
|
|
31
30
|
}>;
|
|
31
|
+
readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
32
|
+
description: "The prefix for the benchmark to show at the start of the line";
|
|
33
|
+
}>;
|
|
32
34
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
33
35
|
description: "Clear the console before running the script";
|
|
34
36
|
required: true;
|
|
@@ -78,6 +80,11 @@ export declare const executionConfig: {
|
|
|
78
80
|
default: false;
|
|
79
81
|
description: "Set NODE_ENV to \"development\"";
|
|
80
82
|
}>;
|
|
83
|
+
readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
84
|
+
required: true;
|
|
85
|
+
default: false;
|
|
86
|
+
description: "Run the script with ts-node";
|
|
87
|
+
}>;
|
|
81
88
|
};
|
|
82
89
|
readonly listArgument: {
|
|
83
90
|
readonly name: "args for script";
|
|
@@ -89,4 +96,20 @@ export declare const executionConfig: {
|
|
|
89
96
|
readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
|
|
90
97
|
};
|
|
91
98
|
};
|
|
92
|
-
export
|
|
99
|
+
export type ExecuteOptions = ReturnType<typeof mapFlagsToOptions>;
|
|
100
|
+
export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, bin?: Executor): {
|
|
101
|
+
cwd: string;
|
|
102
|
+
shell: boolean;
|
|
103
|
+
showInfo: boolean;
|
|
104
|
+
showTime: boolean;
|
|
105
|
+
benchmark: boolean;
|
|
106
|
+
benchmarkPrefix: string | undefined;
|
|
107
|
+
clearOnReload: boolean;
|
|
108
|
+
readlineReload: boolean;
|
|
109
|
+
watch: boolean;
|
|
110
|
+
watchDelay: number;
|
|
111
|
+
watchIgnore: string[];
|
|
112
|
+
watchExtensions: string[];
|
|
113
|
+
tsNode: boolean;
|
|
114
|
+
env: NodeJS.ProcessEnv;
|
|
115
|
+
};
|
package/dist/arg-helper.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
20
20
|
bench: noarg_1.default.boolean()
|
|
21
21
|
.default(false)
|
|
22
22
|
.description('Show the execution time'),
|
|
23
|
+
benchPrefix: noarg_1.default.string().description('The prefix for the benchmark to show at the start of the line'),
|
|
23
24
|
clear: noarg_1.default.boolean()
|
|
24
25
|
.default(true)
|
|
25
26
|
.description('Clear the console before running the script')
|
|
@@ -50,6 +51,9 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
50
51
|
nodeDev: noarg_1.default.boolean()
|
|
51
52
|
.default(false)
|
|
52
53
|
.description('Set NODE_ENV to "development"'),
|
|
54
|
+
tsn: noarg_1.default.boolean()
|
|
55
|
+
.default(false)
|
|
56
|
+
.description('Run the script with ts-node'),
|
|
53
57
|
},
|
|
54
58
|
listArgument: {
|
|
55
59
|
name: 'args for script',
|
|
@@ -62,19 +66,20 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
62
66
|
},
|
|
63
67
|
});
|
|
64
68
|
function mapFlagsToOptions(flags, bin) {
|
|
65
|
-
var _a, _b;
|
|
66
69
|
return {
|
|
67
70
|
cwd: flags.cwd,
|
|
68
71
|
shell: flags.shell,
|
|
69
72
|
showInfo: flags.info,
|
|
70
73
|
showTime: flags.time,
|
|
71
74
|
benchmark: flags.bench,
|
|
75
|
+
benchmarkPrefix: flags.benchPrefix,
|
|
72
76
|
clearOnReload: flags.clear,
|
|
73
77
|
readlineReload: flags.reloadKey,
|
|
74
78
|
watch: flags.watch,
|
|
75
79
|
watchDelay: flags.delay,
|
|
76
|
-
watchExtensions: (_b = (_a = (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.config.watchExtensions)) !== null && _a !== void 0 ? _a : bin === null || bin === void 0 ? void 0 : bin.config.extensions) !== null && _b !== void 0 ? _b : [],
|
|
77
80
|
watchIgnore: flags.ignore,
|
|
81
|
+
watchExtensions: (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.getRelatedExts()) || [],
|
|
82
|
+
tsNode: flags['tsn'],
|
|
78
83
|
env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
|
|
79
84
|
const [key, value] = env.split('=');
|
|
80
85
|
acc[key] = value;
|
package/dist/arg.d.ts
CHANGED
|
@@ -47,6 +47,9 @@ export declare const app: NoArg<"uni-run", {
|
|
|
47
47
|
default: false;
|
|
48
48
|
description: "Show the execution time";
|
|
49
49
|
}>;
|
|
50
|
+
readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
51
|
+
description: "The prefix for the benchmark to show at the start of the line";
|
|
52
|
+
}>;
|
|
50
53
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
51
54
|
description: "Clear the console before running the script";
|
|
52
55
|
required: true;
|
|
@@ -96,6 +99,11 @@ export declare const app: NoArg<"uni-run", {
|
|
|
96
99
|
default: false;
|
|
97
100
|
description: "Set NODE_ENV to \"development\"";
|
|
98
101
|
}>;
|
|
102
|
+
readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
103
|
+
required: true;
|
|
104
|
+
default: false;
|
|
105
|
+
description: "Run the script with ts-node";
|
|
106
|
+
}>;
|
|
99
107
|
};
|
|
100
108
|
readonly customRenderHelp: {
|
|
101
109
|
readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
|
|
@@ -144,6 +152,9 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
144
152
|
default: false;
|
|
145
153
|
description: "Show the execution time";
|
|
146
154
|
}>;
|
|
155
|
+
readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
156
|
+
description: "The prefix for the benchmark to show at the start of the line";
|
|
157
|
+
}>;
|
|
147
158
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
148
159
|
description: "Clear the console before running the script";
|
|
149
160
|
required: true;
|
|
@@ -193,13 +204,18 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
193
204
|
default: false;
|
|
194
205
|
description: "Set NODE_ENV to \"development\"";
|
|
195
206
|
}>;
|
|
207
|
+
readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
208
|
+
required: true;
|
|
209
|
+
default: false;
|
|
210
|
+
description: "Run the script with ts-node";
|
|
211
|
+
}>;
|
|
196
212
|
};
|
|
197
213
|
readonly customRenderHelp: {
|
|
198
214
|
readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
|
|
199
215
|
};
|
|
200
216
|
globalFlags: {};
|
|
201
217
|
}>;
|
|
202
|
-
export declare const
|
|
218
|
+
export declare const list: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"list", {
|
|
203
219
|
readonly allowEqualAssign: true;
|
|
204
220
|
readonly booleanNotSyntaxEnding: "\\";
|
|
205
221
|
readonly allowDuplicateFlagForList: true;
|
package/dist/arg.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.list = exports.exec = exports.app = void 0;
|
|
4
4
|
const noarg_1 = require("noarg");
|
|
5
5
|
const arg_helper_1 = require("./arg-helper");
|
|
6
6
|
exports.app = noarg_1.default.create('uni-run', Object.assign(Object.assign({}, arg_helper_1.executionConfig), { description: 'A universal runner for scripts', system: { splitListByComma: true }, arguments: [
|
|
7
7
|
{ name: 'script', type: noarg_1.default.string(), description: 'Run a script' },
|
|
8
8
|
] }));
|
|
9
9
|
exports.exec = exports.app.create('exec', Object.assign(Object.assign({}, arg_helper_1.executionConfig), { description: 'Execute a script with the given binary' }));
|
|
10
|
-
exports.
|
|
10
|
+
exports.list = exports.app.create('list', {
|
|
11
11
|
description: 'List supported scripts',
|
|
12
12
|
});
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ExecuteOptions } from '../arg-helper';
|
|
2
|
+
type BinConfig = {
|
|
3
3
|
extensions: string[];
|
|
4
4
|
watchExtensions?: string[];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
command: string;
|
|
10
|
-
args: string[];
|
|
11
|
-
}[];
|
|
5
|
+
run: (args: string[], options: ExecuteOptions) => string[];
|
|
6
|
+
installMessage?: string;
|
|
7
|
+
installCommands?: string[] | ((options: ExecuteOptions) => string[]);
|
|
8
|
+
checkInstallation?: string[] | ((options: ExecuteOptions) => string[]);
|
|
12
9
|
};
|
|
13
10
|
export default class Executor {
|
|
14
|
-
name
|
|
15
|
-
config
|
|
16
|
-
constructor(name: string, config:
|
|
17
|
-
|
|
11
|
+
private name;
|
|
12
|
+
private config;
|
|
13
|
+
constructor(name: string, config: BinConfig);
|
|
14
|
+
getName(): string;
|
|
15
|
+
getRelatedExts(): string[];
|
|
16
|
+
start(options: ExecuteOptions, args: string[]): void;
|
|
18
17
|
isSupported(script: string): boolean;
|
|
19
|
-
isInstalled
|
|
20
|
-
renderHowToInstall
|
|
18
|
+
private isInstalled;
|
|
19
|
+
private renderHowToInstall;
|
|
21
20
|
}
|
|
22
21
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const execution_1 = require("../execution");
|
|
3
4
|
const confirm_1 = require("@inquirer/confirm");
|
|
4
5
|
const cross_spawn_1 = require("cross-spawn");
|
|
5
6
|
class Executor {
|
|
@@ -9,33 +10,50 @@ class Executor {
|
|
|
9
10
|
this.config = config;
|
|
10
11
|
(_a = this.config.watchExtensions) === null || _a === void 0 ? void 0 : _a.push(...this.config.extensions);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
getName() {
|
|
14
|
+
return this.name;
|
|
15
|
+
}
|
|
16
|
+
getRelatedExts() {
|
|
13
17
|
var _a;
|
|
14
|
-
return [this.config.
|
|
18
|
+
return [...this.config.extensions, ...((_a = this.config.watchExtensions) !== null && _a !== void 0 ? _a : [])];
|
|
19
|
+
}
|
|
20
|
+
start(options, args) {
|
|
21
|
+
if (!this.isInstalled(options)) {
|
|
22
|
+
return this.renderHowToInstall(options);
|
|
23
|
+
}
|
|
24
|
+
execution_1.default.start(this.config.run(args, options), options);
|
|
15
25
|
}
|
|
16
26
|
isSupported(script) {
|
|
17
27
|
return this.config.extensions.includes(script.split('.').pop() || '');
|
|
18
28
|
}
|
|
19
|
-
isInstalled() {
|
|
20
|
-
|
|
29
|
+
isInstalled(options) {
|
|
30
|
+
if (!this.config.checkInstallation)
|
|
31
|
+
return true;
|
|
32
|
+
const [command, ...args] = typeof this.config.checkInstallation === 'function'
|
|
33
|
+
? this.config.checkInstallation(options)
|
|
34
|
+
: this.config.checkInstallation || [];
|
|
35
|
+
const result = (0, cross_spawn_1.sync)(command, args, {
|
|
36
|
+
stdio: 'ignore',
|
|
37
|
+
});
|
|
21
38
|
if (result.status === 1)
|
|
22
39
|
return false;
|
|
23
40
|
return true;
|
|
24
41
|
}
|
|
25
|
-
renderHowToInstall() {
|
|
26
|
-
var _a;
|
|
42
|
+
renderHowToInstall(options) {
|
|
27
43
|
console.error(`${this.name} is not installed.`);
|
|
28
|
-
if (this.config.
|
|
44
|
+
if (this.config.installMessage) {
|
|
29
45
|
console.log('How to install:');
|
|
30
|
-
this.config.
|
|
46
|
+
console.log(this.config.installMessage);
|
|
31
47
|
}
|
|
32
|
-
|
|
48
|
+
const commands = typeof this.config.installCommands === 'function'
|
|
49
|
+
? this.config.installCommands(options)
|
|
50
|
+
: this.config.installCommands;
|
|
51
|
+
if (!commands || !commands.length)
|
|
33
52
|
return;
|
|
34
53
|
(0, confirm_1.default)({ message: 'Do you want to install it?' }).then((ans) => {
|
|
35
|
-
var _a;
|
|
36
54
|
if (!ans)
|
|
37
55
|
return;
|
|
38
|
-
|
|
56
|
+
commands.forEach(([command, ...args]) => {
|
|
39
57
|
if (!command)
|
|
40
58
|
return;
|
|
41
59
|
(0, cross_spawn_1.sync)(command, args, { stdio: 'inherit' });
|
|
@@ -3,103 +3,94 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const Executor_1 = require("./Executor");
|
|
4
4
|
exports.default = [
|
|
5
5
|
new Executor_1.default('Node.js', {
|
|
6
|
-
command: 'node',
|
|
7
6
|
extensions: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
checkInstallation: ['node', '--version'],
|
|
8
|
+
installMessage: 'Please install Node.js from https://nodejs.org',
|
|
9
|
+
run(args) {
|
|
10
|
+
return ['node', ...args];
|
|
12
11
|
},
|
|
13
12
|
}),
|
|
14
13
|
new Executor_1.default('TypeScript', {
|
|
15
|
-
command: 'ts-node',
|
|
16
14
|
extensions: ['ts', 'tsx', 'cts', 'ctsx', 'mts', 'mtsx'],
|
|
17
|
-
watchExtensions: [
|
|
18
|
-
|
|
19
|
-
'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
checkInstallationArgs: ['--version'],
|
|
30
|
-
installCommands: [{ command: 'npm', args: ['install', '-g', 'ts-node'] }],
|
|
31
|
-
howToInstall: () => {
|
|
32
|
-
console.log('Please install ts-node from https://www.npmjs.com/package/ts-node');
|
|
15
|
+
watchExtensions: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
|
|
16
|
+
checkInstallation(options) {
|
|
17
|
+
return options.tsNode ? ['ts-node', '--version'] : ['tsx', '--version'];
|
|
18
|
+
},
|
|
19
|
+
installCommands(options) {
|
|
20
|
+
return options.tsNode
|
|
21
|
+
? ['npm install -g ts-node']
|
|
22
|
+
: ['npm install -g tsx'];
|
|
23
|
+
},
|
|
24
|
+
installMessage: 'Please install tsx. More: https://tsx.is',
|
|
25
|
+
run(args, options) {
|
|
26
|
+
return options.tsNode ? ['ts-node', ...args] : ['tsx', ...args];
|
|
33
27
|
},
|
|
34
28
|
}),
|
|
35
29
|
new Executor_1.default('Python', {
|
|
36
|
-
command: 'python',
|
|
37
30
|
extensions: ['py'],
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
checkInstallation: ['python', '--version'],
|
|
32
|
+
installMessage: 'Please install Python from https://www.python.org',
|
|
33
|
+
run(args) {
|
|
34
|
+
return ['python', ...args];
|
|
41
35
|
},
|
|
42
36
|
}),
|
|
43
37
|
new Executor_1.default('Java - Oracle', {
|
|
44
|
-
command: 'java',
|
|
45
38
|
extensions: ['java'],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
checkInstallation: ['java', '--version'],
|
|
40
|
+
installMessage: 'Please install Java from https://www.oracle.com/java',
|
|
41
|
+
run(args) {
|
|
42
|
+
return ['java', ...args];
|
|
49
43
|
},
|
|
50
44
|
}),
|
|
51
45
|
new Executor_1.default('Powershell', {
|
|
52
|
-
command: 'powershell',
|
|
53
46
|
extensions: ['ps1'],
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
checkInstallation: ['powershell', '-command', 'echo ok'],
|
|
48
|
+
installMessage: 'Please install Powershell from https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell',
|
|
49
|
+
run(args) {
|
|
50
|
+
return ['powershell', '-File', ...args];
|
|
57
51
|
},
|
|
58
52
|
}),
|
|
59
53
|
new Executor_1.default('Command Prompt', {
|
|
60
|
-
command: 'cmd',
|
|
61
|
-
runArgs: ['/c'],
|
|
62
54
|
extensions: ['cmd', 'bat'],
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
checkInstallation: ['cmd', '/c', 'echo ok'],
|
|
56
|
+
installMessage: 'Please install Command Prompt from Windows',
|
|
57
|
+
run(args) {
|
|
58
|
+
return ['cmd', '/c', ...args];
|
|
66
59
|
},
|
|
67
60
|
}),
|
|
68
61
|
new Executor_1.default('Shell', {
|
|
69
|
-
command: 'bash',
|
|
70
62
|
extensions: ['sh'],
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
checkInstallation: ['bash', '--version'],
|
|
64
|
+
installMessage: 'Please install Bash from https://www.gnu.org/software/bash',
|
|
65
|
+
run(args) {
|
|
66
|
+
return ['bash', ...args];
|
|
74
67
|
},
|
|
75
68
|
}),
|
|
76
69
|
new Executor_1.default('Lua', {
|
|
77
|
-
command: 'lua',
|
|
78
70
|
extensions: ['lua'],
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
checkInstallation: ['lua', '--version'],
|
|
72
|
+
installMessage: 'Please install Lua from https://www.lua.org',
|
|
73
|
+
run(args) {
|
|
74
|
+
return ['lua', ...args];
|
|
82
75
|
},
|
|
83
76
|
}),
|
|
84
77
|
new Executor_1.default('SASS (CSS)', {
|
|
85
|
-
command: 'sass',
|
|
86
78
|
extensions: ['sass', 'scss'],
|
|
87
|
-
|
|
88
|
-
installCommands: [
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
checkInstallation: ['sass', '--version'],
|
|
80
|
+
installCommands: ['npm install -g sass'],
|
|
81
|
+
installMessage: 'Please install SASS from https://sass-lang.com',
|
|
82
|
+
run(args) {
|
|
83
|
+
return ['sass', ...args];
|
|
91
84
|
},
|
|
92
85
|
}),
|
|
93
86
|
new Executor_1.default('HTML Server', {
|
|
94
|
-
command: 'http-server',
|
|
95
87
|
extensions: ['html', 'htm'],
|
|
96
88
|
watchExtensions: ['css', 'js', 'javascript', 'json'],
|
|
97
|
-
|
|
98
|
-
installCommands: [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
console.log('Please install http-server from https://www.npmjs.com/package/http-server');
|
|
89
|
+
checkInstallation: ['http-server', '--version'],
|
|
90
|
+
installCommands: ['npm install -g http-server'],
|
|
91
|
+
installMessage: 'Please install http-server from https://www.npmjs.com/package/http-server',
|
|
92
|
+
run(args) {
|
|
93
|
+
return ['http-server', ...args];
|
|
103
94
|
},
|
|
104
95
|
}),
|
|
105
96
|
];
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { ExecuteOptions } from '../arg-helper';
|
|
1
2
|
export default class Execution {
|
|
2
3
|
private command;
|
|
3
4
|
private args;
|
|
4
5
|
private options;
|
|
5
6
|
private child;
|
|
7
|
+
private benchMarkText;
|
|
8
|
+
private isBenchmarkRunning;
|
|
6
9
|
static start([command, ...args]: string[], options: ExecuteOptions): Execution;
|
|
7
10
|
constructor(command: string, args: string[], options: ExecuteOptions);
|
|
8
11
|
private setup;
|
|
@@ -10,17 +13,3 @@ export default class Execution {
|
|
|
10
13
|
private killProcess;
|
|
11
14
|
private clearBeforeStart;
|
|
12
15
|
}
|
|
13
|
-
export type ExecuteOptions = {
|
|
14
|
-
cwd: string;
|
|
15
|
-
clearOnReload: boolean;
|
|
16
|
-
readlineReload: boolean;
|
|
17
|
-
watch: boolean;
|
|
18
|
-
watchDelay: number;
|
|
19
|
-
watchIgnore: string[];
|
|
20
|
-
watchExtensions: string[];
|
|
21
|
-
env: Record<string, string>;
|
|
22
|
-
shell: boolean;
|
|
23
|
-
showInfo: boolean;
|
|
24
|
-
showTime: boolean;
|
|
25
|
-
benchmark: boolean;
|
|
26
|
-
};
|
package/dist/execution/index.js
CHANGED
|
@@ -14,11 +14,17 @@ class Execution {
|
|
|
14
14
|
this.args = args;
|
|
15
15
|
this.options = options;
|
|
16
16
|
this.child = null;
|
|
17
|
+
this.benchMarkText = colors_1.default.dim.blue('> Execution time');
|
|
18
|
+
this.isBenchmarkRunning = false;
|
|
17
19
|
this.setup();
|
|
18
20
|
this.runProcess();
|
|
19
21
|
}
|
|
20
22
|
setup() {
|
|
21
23
|
var _a, _b;
|
|
24
|
+
if (this.options.benchmarkPrefix) {
|
|
25
|
+
this.benchMarkText =
|
|
26
|
+
colors_1.default.bold(this.options.benchmarkPrefix) + ' ' + this.benchMarkText;
|
|
27
|
+
}
|
|
22
28
|
if (this.options.readlineReload) {
|
|
23
29
|
readline.emitKeypressEvents(process.stdin);
|
|
24
30
|
(_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
|
|
@@ -47,7 +53,13 @@ class Execution {
|
|
|
47
53
|
console.log('@', colors_1.default.yellow(new Date().toLocaleString()));
|
|
48
54
|
}
|
|
49
55
|
if (this.options.benchmark) {
|
|
50
|
-
|
|
56
|
+
if (this.isBenchmarkRunning) {
|
|
57
|
+
console.timeEnd(this.benchMarkText);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.isBenchmarkRunning = true;
|
|
61
|
+
}
|
|
62
|
+
console.time(this.benchMarkText);
|
|
51
63
|
}
|
|
52
64
|
this.child = (0, cross_spawn_1.spawn)(this.command, this.args, {
|
|
53
65
|
stdio: 'inherit',
|
|
@@ -62,7 +74,8 @@ class Execution {
|
|
|
62
74
|
console.log(colors_1.default.red(`Process exited with code: ${colors_1.default.yellow(String(code))}`));
|
|
63
75
|
}
|
|
64
76
|
if (this.options.benchmark) {
|
|
65
|
-
|
|
77
|
+
this.isBenchmarkRunning = false;
|
|
78
|
+
console.timeEnd(this.benchMarkText);
|
|
66
79
|
}
|
|
67
80
|
if (this.options.watch && this.options.showInfo) {
|
|
68
81
|
console.log(colors_1.default.dim.blue('> Watching for extensions:'), colors_1.default.dim(this.options.watchExtensions
|
package/dist/index.js
CHANGED
|
@@ -10,25 +10,25 @@ arg.app.on(([script, listArs, trailingArgs], flags) => {
|
|
|
10
10
|
console.log('Unsupported script:', script);
|
|
11
11
|
return console.log('You may try "ur exec bin script.ext - --flags"');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
execution_1.default.start(bin.getArgs(script, ...listArs, ...trailingArgs), (0, arg_helper_1.mapFlagsToOptions)(flags, bin));
|
|
13
|
+
const executionOptions = (0, arg_helper_1.mapFlagsToOptions)(flags, bin);
|
|
14
|
+
bin.start(executionOptions, [script, ...listArs, ...trailingArgs]);
|
|
17
15
|
});
|
|
18
16
|
arg.exec.on(([listArs, trailingArgs], flags) => {
|
|
19
17
|
execution_1.default.start([...listArs, ...trailingArgs], (0, arg_helper_1.mapFlagsToOptions)(flags));
|
|
20
18
|
});
|
|
21
|
-
arg.
|
|
19
|
+
arg.list.on(() => {
|
|
22
20
|
console.log('Supported scripts:');
|
|
23
21
|
builtin_bin_1.default
|
|
24
22
|
.sort((a, b) => {
|
|
25
|
-
|
|
23
|
+
const aName = a.getName();
|
|
24
|
+
const bName = b.getName();
|
|
25
|
+
if (aName < bName)
|
|
26
26
|
return -1;
|
|
27
|
-
if (
|
|
27
|
+
if (aName > bName)
|
|
28
28
|
return 1;
|
|
29
29
|
return 0;
|
|
30
30
|
})
|
|
31
31
|
.forEach((bin) => {
|
|
32
|
-
console.log(`- ${bin.
|
|
32
|
+
console.log(`- ${bin.getName()}`);
|
|
33
33
|
});
|
|
34
34
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uni-run",
|
|
3
3
|
"description": "Universal Runner for many language",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"ts": "
|
|
8
|
-
"js": "
|
|
7
|
+
"ts": "tsx --watch ./src/__lab__/index.ts",
|
|
8
|
+
"js": "node --watch ./dist/__lab__/index.js",
|
|
9
|
+
"tsc": "tsc --watch --noEmit",
|
|
9
10
|
"dev": "tsc --watch",
|
|
10
11
|
"build": "node ./build.cjs"
|
|
11
12
|
},
|
|
@@ -22,8 +23,8 @@
|
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/cross-spawn": "^6.0.6",
|
|
25
|
-
"@types/node": "^22.5.
|
|
26
|
-
"typescript": "^5.
|
|
26
|
+
"@types/node": "^22.5.5",
|
|
27
|
+
"typescript": "^5.6.2"
|
|
27
28
|
},
|
|
28
29
|
"repository": {
|
|
29
30
|
"type": "git",
|