uni-run 1.0.4 → 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 +4 -0
- package/dist/arg-helper.js +2 -0
- package/dist/arg.d.ts +6 -0
- package/dist/execution/index.d.ts +2 -0
- package/dist/execution/index.js +15 -2
- package/dist/execution/watcher.js +1 -1
- package/package.json +3 -3
package/dist/arg-helper.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ export declare const executionConfig: {
|
|
|
28
28
|
default: false;
|
|
29
29
|
description: "Show the execution time";
|
|
30
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
|
+
}>;
|
|
31
34
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
32
35
|
description: "Clear the console before running the script";
|
|
33
36
|
required: true;
|
|
@@ -100,6 +103,7 @@ export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, b
|
|
|
100
103
|
showInfo: boolean;
|
|
101
104
|
showTime: boolean;
|
|
102
105
|
benchmark: boolean;
|
|
106
|
+
benchmarkPrefix: string | undefined;
|
|
103
107
|
clearOnReload: boolean;
|
|
104
108
|
readlineReload: boolean;
|
|
105
109
|
watch: boolean;
|
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')
|
|
@@ -71,6 +72,7 @@ function mapFlagsToOptions(flags, bin) {
|
|
|
71
72
|
showInfo: flags.info,
|
|
72
73
|
showTime: flags.time,
|
|
73
74
|
benchmark: flags.bench,
|
|
75
|
+
benchmarkPrefix: flags.benchPrefix,
|
|
74
76
|
clearOnReload: flags.clear,
|
|
75
77
|
readlineReload: flags.reloadKey,
|
|
76
78
|
watch: flags.watch,
|
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;
|
|
@@ -149,6 +152,9 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
149
152
|
default: false;
|
|
150
153
|
description: "Show the execution time";
|
|
151
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
|
+
}>;
|
|
152
158
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
153
159
|
description: "Clear the console before running the script";
|
|
154
160
|
required: true;
|
|
@@ -4,6 +4,8 @@ export default class Execution {
|
|
|
4
4
|
private args;
|
|
5
5
|
private options;
|
|
6
6
|
private child;
|
|
7
|
+
private benchMarkText;
|
|
8
|
+
private isBenchmarkRunning;
|
|
7
9
|
static start([command, ...args]: string[], options: ExecuteOptions): Execution;
|
|
8
10
|
constructor(command: string, args: string[], options: ExecuteOptions);
|
|
9
11
|
private setup;
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
7
|
"ts": "tsx --watch ./src/__lab__/index.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/cross-spawn": "^6.0.6",
|
|
26
|
-
"@types/node": "^22.5.
|
|
27
|
-
"typescript": "^5.
|
|
26
|
+
"@types/node": "^22.5.5",
|
|
27
|
+
"typescript": "^5.6.2"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|