uni-run 1.0.7 → 1.0.8

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.
@@ -8,21 +8,18 @@ exports.mapFlagsToOptions = mapFlagsToOptions;
8
8
  const noarg_1 = __importDefault(require("noarg"));
9
9
  exports.executionConfig = noarg_1.default.defineConfig({
10
10
  flags: {
11
- reloadKey: noarg_1.default.boolean()
12
- .aliases('rk')
11
+ // Watch/Reload flags
12
+ 'key-reload': noarg_1.default.boolean()
13
+ .aliases('k')
13
14
  .default(true)
14
15
  .description("Reload the page when pressing 'Ctrl+R' or 'F5'"),
15
16
  watch: noarg_1.default.boolean()
16
17
  .aliases('w')
17
18
  .default(true)
18
- .description('Watch for changes'),
19
+ .description('Watch for file changes and reload the script'),
19
20
  exit: noarg_1.default.boolean()
20
21
  .default(false)
21
22
  .description('Exit after code execution, disabling `watch` and `reloadKey`'),
22
- clear: noarg_1.default.boolean()
23
- .aliases('c')
24
- .default(true)
25
- .description('Clear the console before running the script'),
26
23
  delay: noarg_1.default.number()
27
24
  .aliases('d')
28
25
  .default(100)
@@ -31,27 +28,35 @@ exports.executionConfig = noarg_1.default.defineConfig({
31
28
  .aliases('e')
32
29
  .default([])
33
30
  .description('Looks for changes only of the given extensions'),
34
- include: noarg_1.default.array(noarg_1.default.string())
35
- .aliases('in')
31
+ focus: noarg_1.default.array(noarg_1.default.string())
32
+ .aliases('f')
36
33
  .default([])
37
- .description('Only watch the given folders/files'),
38
- exclude: noarg_1.default.array(noarg_1.default.string())
39
- .aliases('ex')
34
+ .description('Only watch the given items. `chokidar` syntax'),
35
+ ignore: noarg_1.default.array(noarg_1.default.string())
36
+ .aliases('ig')
40
37
  .default([])
41
- .description('Exclude the given folders/files'),
38
+ .description('Exclude the given items. `gitignore` syntax'),
39
+ // Benchmark flags
42
40
  bench: noarg_1.default.boolean()
43
41
  .aliases('b')
44
42
  .description('Calculate the execution time'),
45
- benchPrefix: noarg_1.default.string()
43
+ 'bench-prefix': noarg_1.default.string()
46
44
  .aliases('bp')
47
45
  .minLength(1)
48
46
  .description('The prefix to show before the execution time'),
47
+ clear: noarg_1.default.boolean()
48
+ .aliases('c')
49
+ .default(true)
50
+ .description('Clear the console before running the script'),
49
51
  cwd: noarg_1.default.string()
50
52
  .default(process.cwd())
51
53
  .description('Current working directory'),
52
54
  shell: noarg_1.default.boolean()
53
55
  .default(false)
54
56
  .description('Run the script in a shell for more low-level control'),
57
+ 'safe-stdin': noarg_1.default.boolean()
58
+ .default(false)
59
+ .description('Disable raw mode for stdin (useful for some scripts)'),
55
60
  info: noarg_1.default.boolean()
56
61
  .default(false)
57
62
  .description('Show information about the script'),
@@ -62,12 +67,12 @@ exports.executionConfig = noarg_1.default.defineConfig({
62
67
  .default([])
63
68
  .description('Environment variables'),
64
69
  // Extra flags
65
- nodeDev: noarg_1.default.boolean()
70
+ 'node-dev': noarg_1.default.boolean()
66
71
  .default(false)
67
72
  .description('Set NODE_ENV to "development"'),
68
73
  tsn: noarg_1.default.boolean()
69
74
  .default(false)
70
- .description('Run the script with ts-node'),
75
+ .description('Run the script with ts-node (TypeScript)'),
71
76
  },
72
77
  listArgument: {
73
78
  name: 'args for script',
@@ -84,22 +89,23 @@ function mapFlagsToOptions(flags, bin) {
84
89
  return {
85
90
  cwd: flags.cwd,
86
91
  shell: flags.shell,
92
+ stdinSafeMode: flags['safe-stdin'],
87
93
  showInfo: flags.info,
88
94
  showTime: flags.time,
89
- benchmark: (_a = flags.bench) !== null && _a !== void 0 ? _a : Boolean(flags.benchPrefix),
90
- benchmarkPrefix: flags.benchPrefix,
95
+ benchmark: (_a = flags.bench) !== null && _a !== void 0 ? _a : Boolean(flags['bench-prefix']),
96
+ benchmarkPrefix: flags['bench-prefix'],
91
97
  clearOnReload: flags.clear,
92
- keystrokeReload: flags.exit ? false : flags.reloadKey,
98
+ keystrokeReload: flags.exit ? false : flags['key-reload'],
93
99
  watch: flags.exit ? false : flags.watch,
94
100
  watchDelay: flags.delay,
95
- watchInclude: flags.include,
96
- watchExclude: flags.exclude,
101
+ watchFocus: flags.focus.length ? flags.focus : [flags.cwd],
102
+ watchIgnore: flags.ignore,
97
103
  watchExtensions: (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.getRelatedExts()) || [],
98
104
  tsNode: flags['tsn'],
99
105
  env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
100
106
  const [key, value] = env.split('=');
101
107
  acc[key] = value;
102
108
  return acc;
103
- }, {})), (flags.nodeDev ? { NODE_ENV: 'development' } : {})),
109
+ }, {})), (flags['node-dev'] ? { NODE_ENV: 'development' } : {})),
104
110
  };
105
111
  }
@@ -3,8 +3,8 @@ import type { app } from "./arg.cjs";
3
3
  import Executor from "./builtin-bin/Executor.cjs";
4
4
  export declare const executionConfig: {
5
5
  readonly flags: {
6
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
7
- aliases: ["rk"];
6
+ readonly 'key-reload': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
7
+ aliases: ["k"];
8
8
  required: true;
9
9
  default: true;
10
10
  description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
@@ -13,19 +13,13 @@ export declare const executionConfig: {
13
13
  aliases: ["w"];
14
14
  required: true;
15
15
  default: true;
16
- description: "Watch for changes";
16
+ description: "Watch for file changes and reload the script";
17
17
  }>;
18
18
  readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
19
19
  required: true;
20
20
  default: false;
21
21
  description: "Exit after code execution, disabling `watch` and `reloadKey`";
22
22
  }>;
23
- readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
24
- aliases: ["c"];
25
- required: true;
26
- default: true;
27
- description: "Clear the console before running the script";
28
- }>;
29
23
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
30
24
  aliases: ["d"];
31
25
  required: true;
@@ -39,29 +33,35 @@ export declare const executionConfig: {
39
33
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
40
34
  description: "Looks for changes only of the given extensions";
41
35
  }>;
42
- readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
43
- aliases: ["in"];
36
+ readonly focus: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
37
+ aliases: ["f"];
44
38
  required: true;
45
39
  default: never[];
46
40
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
47
- description: "Only watch the given folders/files";
41
+ description: "Only watch the given items. `chokidar` syntax";
48
42
  }>;
49
- readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
50
- aliases: ["ex"];
43
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
44
+ aliases: ["ig"];
51
45
  required: true;
52
46
  default: never[];
53
47
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
54
- description: "Exclude the given folders/files";
48
+ description: "Exclude the given items. `gitignore` syntax";
55
49
  }>;
56
50
  readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
57
51
  aliases: ["b"];
58
52
  description: "Calculate the execution time";
59
53
  }>;
60
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
54
+ readonly 'bench-prefix': import("noarg/dist/schema/TypeString.cjs").TypeString<{
61
55
  aliases: ["bp"];
62
56
  minLength: 1;
63
57
  description: "The prefix to show before the execution time";
64
58
  }>;
59
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
60
+ aliases: ["c"];
61
+ required: true;
62
+ default: true;
63
+ description: "Clear the console before running the script";
64
+ }>;
65
65
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
66
66
  required: true;
67
67
  default: string;
@@ -72,6 +72,11 @@ export declare const executionConfig: {
72
72
  default: false;
73
73
  description: "Run the script in a shell for more low-level control";
74
74
  }>;
75
+ readonly 'safe-stdin': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
76
+ required: true;
77
+ default: false;
78
+ description: "Disable raw mode for stdin (useful for some scripts)";
79
+ }>;
75
80
  readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
76
81
  required: true;
77
82
  default: false;
@@ -88,7 +93,7 @@ export declare const executionConfig: {
88
93
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
89
94
  description: "Environment variables";
90
95
  }>;
91
- readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
96
+ readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
92
97
  required: true;
93
98
  default: false;
94
99
  description: "Set NODE_ENV to \"development\"";
@@ -96,7 +101,7 @@ export declare const executionConfig: {
96
101
  readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
97
102
  required: true;
98
103
  default: false;
99
- description: "Run the script with ts-node";
104
+ description: "Run the script with ts-node (TypeScript)";
100
105
  }>;
101
106
  };
102
107
  readonly listArgument: {
@@ -113,6 +118,7 @@ export type ExecuteOptions = ReturnType<typeof mapFlagsToOptions>;
113
118
  export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, bin?: Executor): {
114
119
  cwd: string;
115
120
  shell: boolean;
121
+ stdinSafeMode: boolean;
116
122
  showInfo: boolean;
117
123
  showTime: boolean;
118
124
  benchmark: boolean;
@@ -121,8 +127,8 @@ export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, b
121
127
  keystrokeReload: boolean;
122
128
  watch: boolean;
123
129
  watchDelay: number;
124
- watchInclude: string[];
125
- watchExclude: string[];
130
+ watchFocus: string[];
131
+ watchIgnore: string[];
126
132
  watchExtensions: string[];
127
133
  tsNode: boolean;
128
134
  env: NodeJS.ProcessEnv;
@@ -3,8 +3,8 @@ import type { app } from "./arg.mjs";
3
3
  import Executor from "./builtin-bin/Executor.mjs";
4
4
  export declare const executionConfig: {
5
5
  readonly flags: {
6
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
7
- aliases: ["rk"];
6
+ readonly 'key-reload': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
7
+ aliases: ["k"];
8
8
  required: true;
9
9
  default: true;
10
10
  description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
@@ -13,19 +13,13 @@ export declare const executionConfig: {
13
13
  aliases: ["w"];
14
14
  required: true;
15
15
  default: true;
16
- description: "Watch for changes";
16
+ description: "Watch for file changes and reload the script";
17
17
  }>;
18
18
  readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
19
19
  required: true;
20
20
  default: false;
21
21
  description: "Exit after code execution, disabling `watch` and `reloadKey`";
22
22
  }>;
23
- readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
24
- aliases: ["c"];
25
- required: true;
26
- default: true;
27
- description: "Clear the console before running the script";
28
- }>;
29
23
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
30
24
  aliases: ["d"];
31
25
  required: true;
@@ -39,29 +33,35 @@ export declare const executionConfig: {
39
33
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
40
34
  description: "Looks for changes only of the given extensions";
41
35
  }>;
42
- readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
43
- aliases: ["in"];
36
+ readonly focus: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
37
+ aliases: ["f"];
44
38
  required: true;
45
39
  default: never[];
46
40
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
47
- description: "Only watch the given folders/files";
41
+ description: "Only watch the given items. `chokidar` syntax";
48
42
  }>;
49
- readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
50
- aliases: ["ex"];
43
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
44
+ aliases: ["ig"];
51
45
  required: true;
52
46
  default: never[];
53
47
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
54
- description: "Exclude the given folders/files";
48
+ description: "Exclude the given items. `gitignore` syntax";
55
49
  }>;
56
50
  readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
57
51
  aliases: ["b"];
58
52
  description: "Calculate the execution time";
59
53
  }>;
60
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
54
+ readonly 'bench-prefix': import("noarg/dist/schema/TypeString.cjs").TypeString<{
61
55
  aliases: ["bp"];
62
56
  minLength: 1;
63
57
  description: "The prefix to show before the execution time";
64
58
  }>;
59
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
60
+ aliases: ["c"];
61
+ required: true;
62
+ default: true;
63
+ description: "Clear the console before running the script";
64
+ }>;
65
65
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
66
66
  required: true;
67
67
  default: string;
@@ -72,6 +72,11 @@ export declare const executionConfig: {
72
72
  default: false;
73
73
  description: "Run the script in a shell for more low-level control";
74
74
  }>;
75
+ readonly 'safe-stdin': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
76
+ required: true;
77
+ default: false;
78
+ description: "Disable raw mode for stdin (useful for some scripts)";
79
+ }>;
75
80
  readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
76
81
  required: true;
77
82
  default: false;
@@ -88,7 +93,7 @@ export declare const executionConfig: {
88
93
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
89
94
  description: "Environment variables";
90
95
  }>;
91
- readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
96
+ readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
92
97
  required: true;
93
98
  default: false;
94
99
  description: "Set NODE_ENV to \"development\"";
@@ -96,7 +101,7 @@ export declare const executionConfig: {
96
101
  readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
97
102
  required: true;
98
103
  default: false;
99
- description: "Run the script with ts-node";
104
+ description: "Run the script with ts-node (TypeScript)";
100
105
  }>;
101
106
  };
102
107
  readonly listArgument: {
@@ -113,6 +118,7 @@ export type ExecuteOptions = ReturnType<typeof mapFlagsToOptions>;
113
118
  export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, bin?: Executor): {
114
119
  cwd: string;
115
120
  shell: boolean;
121
+ stdinSafeMode: boolean;
116
122
  showInfo: boolean;
117
123
  showTime: boolean;
118
124
  benchmark: boolean;
@@ -121,8 +127,8 @@ export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, b
121
127
  keystrokeReload: boolean;
122
128
  watch: boolean;
123
129
  watchDelay: number;
124
- watchInclude: string[];
125
- watchExclude: string[];
130
+ watchFocus: string[];
131
+ watchIgnore: string[];
126
132
  watchExtensions: string[];
127
133
  tsNode: boolean;
128
134
  env: NodeJS.ProcessEnv;
@@ -1,21 +1,18 @@
1
1
  import NoArg from "noarg";
2
2
  export const executionConfig = NoArg.defineConfig({
3
3
  flags: {
4
- reloadKey: NoArg.boolean()
5
- .aliases('rk')
4
+ // Watch/Reload flags
5
+ 'key-reload': NoArg.boolean()
6
+ .aliases('k')
6
7
  .default(true)
7
8
  .description("Reload the page when pressing 'Ctrl+R' or 'F5'"),
8
9
  watch: NoArg.boolean()
9
10
  .aliases('w')
10
11
  .default(true)
11
- .description('Watch for changes'),
12
+ .description('Watch for file changes and reload the script'),
12
13
  exit: NoArg.boolean()
13
14
  .default(false)
14
15
  .description('Exit after code execution, disabling `watch` and `reloadKey`'),
15
- clear: NoArg.boolean()
16
- .aliases('c')
17
- .default(true)
18
- .description('Clear the console before running the script'),
19
16
  delay: NoArg.number()
20
17
  .aliases('d')
21
18
  .default(100)
@@ -24,27 +21,35 @@ export const executionConfig = NoArg.defineConfig({
24
21
  .aliases('e')
25
22
  .default([])
26
23
  .description('Looks for changes only of the given extensions'),
27
- include: NoArg.array(NoArg.string())
28
- .aliases('in')
24
+ focus: NoArg.array(NoArg.string())
25
+ .aliases('f')
29
26
  .default([])
30
- .description('Only watch the given folders/files'),
31
- exclude: NoArg.array(NoArg.string())
32
- .aliases('ex')
27
+ .description('Only watch the given items. `chokidar` syntax'),
28
+ ignore: NoArg.array(NoArg.string())
29
+ .aliases('ig')
33
30
  .default([])
34
- .description('Exclude the given folders/files'),
31
+ .description('Exclude the given items. `gitignore` syntax'),
32
+ // Benchmark flags
35
33
  bench: NoArg.boolean()
36
34
  .aliases('b')
37
35
  .description('Calculate the execution time'),
38
- benchPrefix: NoArg.string()
36
+ 'bench-prefix': NoArg.string()
39
37
  .aliases('bp')
40
38
  .minLength(1)
41
39
  .description('The prefix to show before the execution time'),
40
+ clear: NoArg.boolean()
41
+ .aliases('c')
42
+ .default(true)
43
+ .description('Clear the console before running the script'),
42
44
  cwd: NoArg.string()
43
45
  .default(process.cwd())
44
46
  .description('Current working directory'),
45
47
  shell: NoArg.boolean()
46
48
  .default(false)
47
49
  .description('Run the script in a shell for more low-level control'),
50
+ 'safe-stdin': NoArg.boolean()
51
+ .default(false)
52
+ .description('Disable raw mode for stdin (useful for some scripts)'),
48
53
  info: NoArg.boolean()
49
54
  .default(false)
50
55
  .description('Show information about the script'),
@@ -55,12 +60,12 @@ export const executionConfig = NoArg.defineConfig({
55
60
  .default([])
56
61
  .description('Environment variables'),
57
62
  // Extra flags
58
- nodeDev: NoArg.boolean()
63
+ 'node-dev': NoArg.boolean()
59
64
  .default(false)
60
65
  .description('Set NODE_ENV to "development"'),
61
66
  tsn: NoArg.boolean()
62
67
  .default(false)
63
- .description('Run the script with ts-node'),
68
+ .description('Run the script with ts-node (TypeScript)'),
64
69
  },
65
70
  listArgument: {
66
71
  name: 'args for script',
@@ -77,22 +82,23 @@ export function mapFlagsToOptions(flags, bin) {
77
82
  return {
78
83
  cwd: flags.cwd,
79
84
  shell: flags.shell,
85
+ stdinSafeMode: flags['safe-stdin'],
80
86
  showInfo: flags.info,
81
87
  showTime: flags.time,
82
- benchmark: (_a = flags.bench) !== null && _a !== void 0 ? _a : Boolean(flags.benchPrefix),
83
- benchmarkPrefix: flags.benchPrefix,
88
+ benchmark: (_a = flags.bench) !== null && _a !== void 0 ? _a : Boolean(flags['bench-prefix']),
89
+ benchmarkPrefix: flags['bench-prefix'],
84
90
  clearOnReload: flags.clear,
85
- keystrokeReload: flags.exit ? false : flags.reloadKey,
91
+ keystrokeReload: flags.exit ? false : flags['key-reload'],
86
92
  watch: flags.exit ? false : flags.watch,
87
93
  watchDelay: flags.delay,
88
- watchInclude: flags.include,
89
- watchExclude: flags.exclude,
94
+ watchFocus: flags.focus.length ? flags.focus : [flags.cwd],
95
+ watchIgnore: flags.ignore,
90
96
  watchExtensions: (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.getRelatedExts()) || [],
91
97
  tsNode: flags['tsn'],
92
98
  env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
93
99
  const [key, value] = env.split('=');
94
100
  acc[key] = value;
95
101
  return acc;
96
- }, {})), (flags.nodeDev ? { NODE_ENV: 'development' } : {})),
102
+ }, {})), (flags['node-dev'] ? { NODE_ENV: 'development' } : {})),
97
103
  };
98
104
  }
package/dist/arg.d.cts CHANGED
@@ -22,8 +22,8 @@ export declare const app: NoArg<"uni-run", {
22
22
  };
23
23
  readonly trailingArguments: "--";
24
24
  readonly flags: {
25
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
26
- aliases: ["rk"];
25
+ readonly 'key-reload': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
26
+ aliases: ["k"];
27
27
  required: true;
28
28
  default: true;
29
29
  description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
@@ -32,19 +32,13 @@ export declare const app: NoArg<"uni-run", {
32
32
  aliases: ["w"];
33
33
  required: true;
34
34
  default: true;
35
- description: "Watch for changes";
35
+ description: "Watch for file changes and reload the script";
36
36
  }>;
37
37
  readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
38
38
  required: true;
39
39
  default: false;
40
40
  description: "Exit after code execution, disabling `watch` and `reloadKey`";
41
41
  }>;
42
- readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
43
- aliases: ["c"];
44
- required: true;
45
- default: true;
46
- description: "Clear the console before running the script";
47
- }>;
48
42
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
49
43
  aliases: ["d"];
50
44
  required: true;
@@ -58,29 +52,35 @@ export declare const app: NoArg<"uni-run", {
58
52
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
59
53
  description: "Looks for changes only of the given extensions";
60
54
  }>;
61
- readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
62
- aliases: ["in"];
55
+ readonly focus: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
56
+ aliases: ["f"];
63
57
  required: true;
64
58
  default: never[];
65
59
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
66
- description: "Only watch the given folders/files";
60
+ description: "Only watch the given items. `chokidar` syntax";
67
61
  }>;
68
- readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
69
- aliases: ["ex"];
62
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
63
+ aliases: ["ig"];
70
64
  required: true;
71
65
  default: never[];
72
66
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
73
- description: "Exclude the given folders/files";
67
+ description: "Exclude the given items. `gitignore` syntax";
74
68
  }>;
75
69
  readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
76
70
  aliases: ["b"];
77
71
  description: "Calculate the execution time";
78
72
  }>;
79
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
73
+ readonly 'bench-prefix': import("noarg/dist/schema/TypeString.cjs").TypeString<{
80
74
  aliases: ["bp"];
81
75
  minLength: 1;
82
76
  description: "The prefix to show before the execution time";
83
77
  }>;
78
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
79
+ aliases: ["c"];
80
+ required: true;
81
+ default: true;
82
+ description: "Clear the console before running the script";
83
+ }>;
84
84
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
85
85
  required: true;
86
86
  default: string;
@@ -91,6 +91,11 @@ export declare const app: NoArg<"uni-run", {
91
91
  default: false;
92
92
  description: "Run the script in a shell for more low-level control";
93
93
  }>;
94
+ readonly 'safe-stdin': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
95
+ required: true;
96
+ default: false;
97
+ description: "Disable raw mode for stdin (useful for some scripts)";
98
+ }>;
94
99
  readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
95
100
  required: true;
96
101
  default: false;
@@ -107,7 +112,7 @@ export declare const app: NoArg<"uni-run", {
107
112
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
108
113
  description: "Environment variables";
109
114
  }>;
110
- readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
115
+ readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
111
116
  required: true;
112
117
  default: false;
113
118
  description: "Set NODE_ENV to \"development\"";
@@ -115,7 +120,7 @@ export declare const app: NoArg<"uni-run", {
115
120
  readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
116
121
  required: true;
117
122
  default: false;
118
- description: "Run the script with ts-node";
123
+ description: "Run the script with ts-node (TypeScript)";
119
124
  }>;
120
125
  };
121
126
  readonly customRenderHelp: {
@@ -140,8 +145,8 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
140
145
  };
141
146
  readonly trailingArguments: "--";
142
147
  readonly flags: {
143
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
144
- aliases: ["rk"];
148
+ readonly 'key-reload': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
149
+ aliases: ["k"];
145
150
  required: true;
146
151
  default: true;
147
152
  description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
@@ -150,19 +155,13 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
150
155
  aliases: ["w"];
151
156
  required: true;
152
157
  default: true;
153
- description: "Watch for changes";
158
+ description: "Watch for file changes and reload the script";
154
159
  }>;
155
160
  readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
156
161
  required: true;
157
162
  default: false;
158
163
  description: "Exit after code execution, disabling `watch` and `reloadKey`";
159
164
  }>;
160
- readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
161
- aliases: ["c"];
162
- required: true;
163
- default: true;
164
- description: "Clear the console before running the script";
165
- }>;
166
165
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
167
166
  aliases: ["d"];
168
167
  required: true;
@@ -176,29 +175,35 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
176
175
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
177
176
  description: "Looks for changes only of the given extensions";
178
177
  }>;
179
- readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
180
- aliases: ["in"];
178
+ readonly focus: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
179
+ aliases: ["f"];
181
180
  required: true;
182
181
  default: never[];
183
182
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
184
- description: "Only watch the given folders/files";
183
+ description: "Only watch the given items. `chokidar` syntax";
185
184
  }>;
186
- readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
187
- aliases: ["ex"];
185
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
186
+ aliases: ["ig"];
188
187
  required: true;
189
188
  default: never[];
190
189
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
191
- description: "Exclude the given folders/files";
190
+ description: "Exclude the given items. `gitignore` syntax";
192
191
  }>;
193
192
  readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
194
193
  aliases: ["b"];
195
194
  description: "Calculate the execution time";
196
195
  }>;
197
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
196
+ readonly 'bench-prefix': import("noarg/dist/schema/TypeString.cjs").TypeString<{
198
197
  aliases: ["bp"];
199
198
  minLength: 1;
200
199
  description: "The prefix to show before the execution time";
201
200
  }>;
201
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
202
+ aliases: ["c"];
203
+ required: true;
204
+ default: true;
205
+ description: "Clear the console before running the script";
206
+ }>;
202
207
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
203
208
  required: true;
204
209
  default: string;
@@ -209,6 +214,11 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
209
214
  default: false;
210
215
  description: "Run the script in a shell for more low-level control";
211
216
  }>;
217
+ readonly 'safe-stdin': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
218
+ required: true;
219
+ default: false;
220
+ description: "Disable raw mode for stdin (useful for some scripts)";
221
+ }>;
212
222
  readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
213
223
  required: true;
214
224
  default: false;
@@ -225,7 +235,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
225
235
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
226
236
  description: "Environment variables";
227
237
  }>;
228
- readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
238
+ readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
229
239
  required: true;
230
240
  default: false;
231
241
  description: "Set NODE_ENV to \"development\"";
@@ -233,7 +243,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
233
243
  readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
234
244
  required: true;
235
245
  default: false;
236
- description: "Run the script with ts-node";
246
+ description: "Run the script with ts-node (TypeScript)";
237
247
  }>;
238
248
  };
239
249
  readonly customRenderHelp: {
package/dist/arg.d.mts CHANGED
@@ -22,8 +22,8 @@ export declare const app: NoArg<"uni-run", {
22
22
  };
23
23
  readonly trailingArguments: "--";
24
24
  readonly flags: {
25
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
26
- aliases: ["rk"];
25
+ readonly 'key-reload': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
26
+ aliases: ["k"];
27
27
  required: true;
28
28
  default: true;
29
29
  description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
@@ -32,19 +32,13 @@ export declare const app: NoArg<"uni-run", {
32
32
  aliases: ["w"];
33
33
  required: true;
34
34
  default: true;
35
- description: "Watch for changes";
35
+ description: "Watch for file changes and reload the script";
36
36
  }>;
37
37
  readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
38
38
  required: true;
39
39
  default: false;
40
40
  description: "Exit after code execution, disabling `watch` and `reloadKey`";
41
41
  }>;
42
- readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
43
- aliases: ["c"];
44
- required: true;
45
- default: true;
46
- description: "Clear the console before running the script";
47
- }>;
48
42
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
49
43
  aliases: ["d"];
50
44
  required: true;
@@ -58,29 +52,35 @@ export declare const app: NoArg<"uni-run", {
58
52
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
59
53
  description: "Looks for changes only of the given extensions";
60
54
  }>;
61
- readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
62
- aliases: ["in"];
55
+ readonly focus: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
56
+ aliases: ["f"];
63
57
  required: true;
64
58
  default: never[];
65
59
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
66
- description: "Only watch the given folders/files";
60
+ description: "Only watch the given items. `chokidar` syntax";
67
61
  }>;
68
- readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
69
- aliases: ["ex"];
62
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
63
+ aliases: ["ig"];
70
64
  required: true;
71
65
  default: never[];
72
66
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
73
- description: "Exclude the given folders/files";
67
+ description: "Exclude the given items. `gitignore` syntax";
74
68
  }>;
75
69
  readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
76
70
  aliases: ["b"];
77
71
  description: "Calculate the execution time";
78
72
  }>;
79
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
73
+ readonly 'bench-prefix': import("noarg/dist/schema/TypeString.cjs").TypeString<{
80
74
  aliases: ["bp"];
81
75
  minLength: 1;
82
76
  description: "The prefix to show before the execution time";
83
77
  }>;
78
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
79
+ aliases: ["c"];
80
+ required: true;
81
+ default: true;
82
+ description: "Clear the console before running the script";
83
+ }>;
84
84
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
85
85
  required: true;
86
86
  default: string;
@@ -91,6 +91,11 @@ export declare const app: NoArg<"uni-run", {
91
91
  default: false;
92
92
  description: "Run the script in a shell for more low-level control";
93
93
  }>;
94
+ readonly 'safe-stdin': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
95
+ required: true;
96
+ default: false;
97
+ description: "Disable raw mode for stdin (useful for some scripts)";
98
+ }>;
94
99
  readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
95
100
  required: true;
96
101
  default: false;
@@ -107,7 +112,7 @@ export declare const app: NoArg<"uni-run", {
107
112
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
108
113
  description: "Environment variables";
109
114
  }>;
110
- readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
115
+ readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
111
116
  required: true;
112
117
  default: false;
113
118
  description: "Set NODE_ENV to \"development\"";
@@ -115,7 +120,7 @@ export declare const app: NoArg<"uni-run", {
115
120
  readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
116
121
  required: true;
117
122
  default: false;
118
- description: "Run the script with ts-node";
123
+ description: "Run the script with ts-node (TypeScript)";
119
124
  }>;
120
125
  };
121
126
  readonly customRenderHelp: {
@@ -140,8 +145,8 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
140
145
  };
141
146
  readonly trailingArguments: "--";
142
147
  readonly flags: {
143
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
144
- aliases: ["rk"];
148
+ readonly 'key-reload': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
149
+ aliases: ["k"];
145
150
  required: true;
146
151
  default: true;
147
152
  description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
@@ -150,19 +155,13 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
150
155
  aliases: ["w"];
151
156
  required: true;
152
157
  default: true;
153
- description: "Watch for changes";
158
+ description: "Watch for file changes and reload the script";
154
159
  }>;
155
160
  readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
156
161
  required: true;
157
162
  default: false;
158
163
  description: "Exit after code execution, disabling `watch` and `reloadKey`";
159
164
  }>;
160
- readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
161
- aliases: ["c"];
162
- required: true;
163
- default: true;
164
- description: "Clear the console before running the script";
165
- }>;
166
165
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
167
166
  aliases: ["d"];
168
167
  required: true;
@@ -176,29 +175,35 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
176
175
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
177
176
  description: "Looks for changes only of the given extensions";
178
177
  }>;
179
- readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
180
- aliases: ["in"];
178
+ readonly focus: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
179
+ aliases: ["f"];
181
180
  required: true;
182
181
  default: never[];
183
182
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
184
- description: "Only watch the given folders/files";
183
+ description: "Only watch the given items. `chokidar` syntax";
185
184
  }>;
186
- readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
187
- aliases: ["ex"];
185
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
186
+ aliases: ["ig"];
188
187
  required: true;
189
188
  default: never[];
190
189
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
191
- description: "Exclude the given folders/files";
190
+ description: "Exclude the given items. `gitignore` syntax";
192
191
  }>;
193
192
  readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
194
193
  aliases: ["b"];
195
194
  description: "Calculate the execution time";
196
195
  }>;
197
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
196
+ readonly 'bench-prefix': import("noarg/dist/schema/TypeString.cjs").TypeString<{
198
197
  aliases: ["bp"];
199
198
  minLength: 1;
200
199
  description: "The prefix to show before the execution time";
201
200
  }>;
201
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
202
+ aliases: ["c"];
203
+ required: true;
204
+ default: true;
205
+ description: "Clear the console before running the script";
206
+ }>;
202
207
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
203
208
  required: true;
204
209
  default: string;
@@ -209,6 +214,11 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
209
214
  default: false;
210
215
  description: "Run the script in a shell for more low-level control";
211
216
  }>;
217
+ readonly 'safe-stdin': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
218
+ required: true;
219
+ default: false;
220
+ description: "Disable raw mode for stdin (useful for some scripts)";
221
+ }>;
212
222
  readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
213
223
  required: true;
214
224
  default: false;
@@ -225,7 +235,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
225
235
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
226
236
  description: "Environment variables";
227
237
  }>;
228
- readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
238
+ readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
229
239
  required: true;
230
240
  default: false;
231
241
  description: "Set NODE_ENV to \"development\"";
@@ -233,7 +243,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
233
243
  readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
234
244
  required: true;
235
245
  default: false;
236
- description: "Run the script with ts-node";
246
+ description: "Run the script with ts-node (TypeScript)";
237
247
  }>;
238
248
  };
239
249
  readonly customRenderHelp: {
@@ -42,8 +42,9 @@ class Execution {
42
42
  this.child = null;
43
43
  this.benchMarkText = colors_1.default.dim.blue('> Execution time');
44
44
  this.isBenchmarkRunning = false;
45
+ this.isExecutionExecutedAnyTime = false;
45
46
  this.setup();
46
- this.runProcess();
47
+ this.startProcess();
47
48
  }
48
49
  setup() {
49
50
  var _a, _b;
@@ -53,62 +54,48 @@ class Execution {
53
54
  }
54
55
  if (this.options.keystrokeReload) {
55
56
  readline.emitKeypressEvents(process.stdin);
56
- (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
57
+ if (!this.options.stdinSafeMode) {
58
+ (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
59
+ }
57
60
  process.stdin.on('keypress', (_, key) => {
58
61
  if (key.name === 'f5' || (key.ctrl && key.name === 'r')) {
59
- return this.runProcess();
62
+ return this.startProcess();
60
63
  }
61
64
  if (key.ctrl && key.name === 'c') {
62
65
  this.killProcess();
63
- return process.exit(0);
66
+ process.exit(0);
64
67
  }
65
68
  });
66
69
  }
67
70
  if (this.options.watch) {
68
- (0, watcher_1.default)(this.options.cwd, this.options.watchInclude.length
69
- ? this.options.watchInclude
70
- : [this.options.cwd], () => this.runProcess(), {
71
- ignore: this.options.watchExclude,
71
+ (0, watcher_1.default)(this.options.cwd, this.options.watchFocus, () => this.startProcess(), {
72
+ ignore: this.options.watchIgnore,
72
73
  debounceDelay: this.options.watchDelay,
73
74
  extensions: new Set(this.options.watchExtensions),
74
75
  });
75
76
  }
76
77
  }
77
- runProcess() {
78
+ startProcess() {
78
79
  this.killProcess();
79
80
  this.clearBeforeStart();
80
- if (this.options.showTime) {
81
- console.log('@', colors_1.default.yellow(new Date().toLocaleString()));
82
- }
83
- if (this.options.benchmark) {
84
- if (this.isBenchmarkRunning) {
85
- console.timeEnd(this.benchMarkText);
86
- }
87
- else {
88
- this.isBenchmarkRunning = true;
89
- }
90
- console.time(this.benchMarkText);
91
- }
81
+ this.renderInfoLogs();
82
+ const controller = new AbortController();
83
+ this.isExecutionExecutedAnyTime = true;
92
84
  this.child = (0, cross_spawn_1.spawn)(this.command, this.args, {
93
85
  stdio: 'inherit',
94
86
  argv0: this.command,
95
87
  cwd: this.options.cwd,
96
88
  shell: this.options.shell,
97
89
  env: Object.assign({}, this.options.env),
90
+ signal: controller.signal,
98
91
  });
99
- this.child.on('error', console.error);
100
92
  this.child.on('exit', (code) => {
101
93
  if (code && code > 0) {
102
94
  console.log(colors_1.default.red(`Process exited with code: ${colors_1.default.yellow(String(code))}`));
103
95
  }
104
- if (this.options.benchmark) {
105
- this.isBenchmarkRunning = false;
96
+ if (this.isBenchmarkRunning) {
106
97
  console.timeEnd(this.benchMarkText);
107
- }
108
- if (this.options.watch && this.options.showInfo) {
109
- console.log(colors_1.default.dim.blue('> Watching for extensions:'), colors_1.default.dim(this.options.watchExtensions
110
- .map((ext) => colors_1.default.yellow(ext))
111
- .join(', ') || colors_1.default.yellow('*')));
98
+ this.isBenchmarkRunning = false;
112
99
  }
113
100
  if (this.options.keystrokeReload) {
114
101
  console.log(colors_1.default.blue.dim(`> Press ${colors_1.default.yellow('F5')} or ${colors_1.default.yellow('^R')} to reload...`));
@@ -119,8 +106,9 @@ class Execution {
119
106
  if (!this.child)
120
107
  return;
121
108
  this.child.removeAllListeners();
122
- if (!(0, kill_process_1.default)(this.child)) {
123
- console.error(colors_1.default.red('Failed to kill the previous process'));
109
+ const isKilled = (0, kill_process_1.default)(this.child);
110
+ if (!isKilled) {
111
+ console.error(colors_1.default.bgRed('ERROR:'), colors_1.default.red('Failed to kill the previous process'));
124
112
  }
125
113
  this.child = null;
126
114
  }
@@ -130,5 +118,39 @@ class Execution {
130
118
  console.clear();
131
119
  }
132
120
  }
121
+ renderInfoLogs() {
122
+ if (this.options.showInfo && !this.isExecutionExecutedAnyTime) {
123
+ if (this.options.watch) {
124
+ console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('Watching for extensions:'), colors_1.default.dim(this.options.watchExtensions
125
+ .map((ext) => colors_1.default.reset(ext))
126
+ .join(', ') || colors_1.default.yellow('*')));
127
+ }
128
+ if (this.options.watchFocus.length) {
129
+ console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('Watching target:'), colors_1.default.dim(this.options.watchFocus
130
+ .map((ext) => colors_1.default.reset(ext))
131
+ .join(', ') || colors_1.default.yellow('*')));
132
+ }
133
+ if (this.options.watchIgnore.length) {
134
+ console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('Watching ignore:'), colors_1.default.dim(this.options.watchIgnore
135
+ .map((ext) => colors_1.default.reset(ext))
136
+ .join(', ') || colors_1.default.yellow('*')));
137
+ }
138
+ if (this.options.shell) {
139
+ console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('SHELL mode enabled'));
140
+ }
141
+ }
142
+ if (this.options.showTime) {
143
+ console.log(colors_1.default.dim.bgGreen('TIME:'), colors_1.default.green(new Date().toLocaleString()));
144
+ }
145
+ if (this.options.benchmark) {
146
+ if (this.isBenchmarkRunning) {
147
+ console.timeEnd(this.benchMarkText);
148
+ }
149
+ else {
150
+ this.isBenchmarkRunning = true;
151
+ }
152
+ console.time(this.benchMarkText);
153
+ }
154
+ }
133
155
  }
134
156
  exports.default = Execution;
@@ -6,10 +6,12 @@ export default class Execution {
6
6
  private child;
7
7
  private benchMarkText;
8
8
  private isBenchmarkRunning;
9
+ private isExecutionExecutedAnyTime;
9
10
  static start([command, ...args]: string[], options: ExecuteOptions): Execution;
10
11
  constructor(command: string, args: string[], options: ExecuteOptions);
11
12
  private setup;
12
- private runProcess;
13
+ private startProcess;
13
14
  private killProcess;
14
15
  private clearBeforeStart;
16
+ private renderInfoLogs;
15
17
  }
@@ -6,10 +6,12 @@ export default class Execution {
6
6
  private child;
7
7
  private benchMarkText;
8
8
  private isBenchmarkRunning;
9
+ private isExecutionExecutedAnyTime;
9
10
  static start([command, ...args]: string[], options: ExecuteOptions): Execution;
10
11
  constructor(command: string, args: string[], options: ExecuteOptions);
11
12
  private setup;
12
- private runProcess;
13
+ private startProcess;
13
14
  private killProcess;
14
15
  private clearBeforeStart;
16
+ private renderInfoLogs;
15
17
  }
@@ -14,8 +14,9 @@ export default class Execution {
14
14
  this.child = null;
15
15
  this.benchMarkText = colors.dim.blue('> Execution time');
16
16
  this.isBenchmarkRunning = false;
17
+ this.isExecutionExecutedAnyTime = false;
17
18
  this.setup();
18
- this.runProcess();
19
+ this.startProcess();
19
20
  }
20
21
  setup() {
21
22
  var _a, _b;
@@ -25,62 +26,48 @@ export default class Execution {
25
26
  }
26
27
  if (this.options.keystrokeReload) {
27
28
  readline.emitKeypressEvents(process.stdin);
28
- (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
29
+ if (!this.options.stdinSafeMode) {
30
+ (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
31
+ }
29
32
  process.stdin.on('keypress', (_, key) => {
30
33
  if (key.name === 'f5' || (key.ctrl && key.name === 'r')) {
31
- return this.runProcess();
34
+ return this.startProcess();
32
35
  }
33
36
  if (key.ctrl && key.name === 'c') {
34
37
  this.killProcess();
35
- return process.exit(0);
38
+ process.exit(0);
36
39
  }
37
40
  });
38
41
  }
39
42
  if (this.options.watch) {
40
- watcher(this.options.cwd, this.options.watchInclude.length
41
- ? this.options.watchInclude
42
- : [this.options.cwd], () => this.runProcess(), {
43
- ignore: this.options.watchExclude,
43
+ watcher(this.options.cwd, this.options.watchFocus, () => this.startProcess(), {
44
+ ignore: this.options.watchIgnore,
44
45
  debounceDelay: this.options.watchDelay,
45
46
  extensions: new Set(this.options.watchExtensions),
46
47
  });
47
48
  }
48
49
  }
49
- runProcess() {
50
+ startProcess() {
50
51
  this.killProcess();
51
52
  this.clearBeforeStart();
52
- if (this.options.showTime) {
53
- console.log('@', colors.yellow(new Date().toLocaleString()));
54
- }
55
- if (this.options.benchmark) {
56
- if (this.isBenchmarkRunning) {
57
- console.timeEnd(this.benchMarkText);
58
- }
59
- else {
60
- this.isBenchmarkRunning = true;
61
- }
62
- console.time(this.benchMarkText);
63
- }
53
+ this.renderInfoLogs();
54
+ const controller = new AbortController();
55
+ this.isExecutionExecutedAnyTime = true;
64
56
  this.child = spawn(this.command, this.args, {
65
57
  stdio: 'inherit',
66
58
  argv0: this.command,
67
59
  cwd: this.options.cwd,
68
60
  shell: this.options.shell,
69
61
  env: Object.assign({}, this.options.env),
62
+ signal: controller.signal,
70
63
  });
71
- this.child.on('error', console.error);
72
64
  this.child.on('exit', (code) => {
73
65
  if (code && code > 0) {
74
66
  console.log(colors.red(`Process exited with code: ${colors.yellow(String(code))}`));
75
67
  }
76
- if (this.options.benchmark) {
77
- this.isBenchmarkRunning = false;
68
+ if (this.isBenchmarkRunning) {
78
69
  console.timeEnd(this.benchMarkText);
79
- }
80
- if (this.options.watch && this.options.showInfo) {
81
- console.log(colors.dim.blue('> Watching for extensions:'), colors.dim(this.options.watchExtensions
82
- .map((ext) => colors.yellow(ext))
83
- .join(', ') || colors.yellow('*')));
70
+ this.isBenchmarkRunning = false;
84
71
  }
85
72
  if (this.options.keystrokeReload) {
86
73
  console.log(colors.blue.dim(`> Press ${colors.yellow('F5')} or ${colors.yellow('^R')} to reload...`));
@@ -91,8 +78,9 @@ export default class Execution {
91
78
  if (!this.child)
92
79
  return;
93
80
  this.child.removeAllListeners();
94
- if (!killProcess(this.child)) {
95
- console.error(colors.red('Failed to kill the previous process'));
81
+ const isKilled = killProcess(this.child);
82
+ if (!isKilled) {
83
+ console.error(colors.bgRed('ERROR:'), colors.red('Failed to kill the previous process'));
96
84
  }
97
85
  this.child = null;
98
86
  }
@@ -102,4 +90,38 @@ export default class Execution {
102
90
  console.clear();
103
91
  }
104
92
  }
93
+ renderInfoLogs() {
94
+ if (this.options.showInfo && !this.isExecutionExecutedAnyTime) {
95
+ if (this.options.watch) {
96
+ console.log(colors.dim.bgGreen('INFO:'), colors.green('Watching for extensions:'), colors.dim(this.options.watchExtensions
97
+ .map((ext) => colors.reset(ext))
98
+ .join(', ') || colors.yellow('*')));
99
+ }
100
+ if (this.options.watchFocus.length) {
101
+ console.log(colors.dim.bgGreen('INFO:'), colors.green('Watching target:'), colors.dim(this.options.watchFocus
102
+ .map((ext) => colors.reset(ext))
103
+ .join(', ') || colors.yellow('*')));
104
+ }
105
+ if (this.options.watchIgnore.length) {
106
+ console.log(colors.dim.bgGreen('INFO:'), colors.green('Watching ignore:'), colors.dim(this.options.watchIgnore
107
+ .map((ext) => colors.reset(ext))
108
+ .join(', ') || colors.yellow('*')));
109
+ }
110
+ if (this.options.shell) {
111
+ console.log(colors.dim.bgGreen('INFO:'), colors.green('SHELL mode enabled'));
112
+ }
113
+ }
114
+ if (this.options.showTime) {
115
+ console.log(colors.dim.bgGreen('TIME:'), colors.green(new Date().toLocaleString()));
116
+ }
117
+ if (this.options.benchmark) {
118
+ if (this.isBenchmarkRunning) {
119
+ console.timeEnd(this.benchMarkText);
120
+ }
121
+ else {
122
+ this.isBenchmarkRunning = true;
123
+ }
124
+ console.time(this.benchMarkText);
125
+ }
126
+ }
105
127
  }
@@ -1 +1 @@
1
- export declare function createDebounce(delay: number): (fn: Function) => void;
1
+ export declare function createDebounce(delay: number): (fn: () => void) => void;
@@ -1 +1 @@
1
- export declare function createDebounce(delay: number): (fn: Function) => void;
1
+ export declare function createDebounce(delay: number): (fn: () => void) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uni-run",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Universal Runner for many language",
5
5
  "scripts": {
6
6
  "dev": "npmize dev",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "ansi-colors": "^4.1.3",
21
- "chokidar": "^3.6.0",
21
+ "chokidar": "^4.0.1",
22
22
  "cross-spawn": "^7.0.3",
23
- "ignore": "^5.3.2",
24
- "noarg": "^3.1.0"
23
+ "ignore": "^6.0.2",
24
+ "noarg": "^3.1.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/cross-spawn": "^6.0.6",
28
- "@types/node": "^22.5.5",
29
- "npmize": "^1.1.3",
28
+ "@types/node": "^22.7.3",
29
+ "npmize": "^1.1.6",
30
30
  "typescript": "^5.6.2"
31
31
  },
32
32
  "repository": {