expensify-common 2.0.194 → 2.0.195
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/CLI.d.ts +5 -0
- package/dist/CLI.js +20 -1
- package/dist/esm/CLI.d.ts +5 -0
- package/dist/esm/CLI.js +20 -1
- package/package.json +1 -1
package/dist/CLI.d.ts
CHANGED
|
@@ -149,6 +149,11 @@ declare class CLI<TConfig extends CLIConfig> {
|
|
|
149
149
|
readonly positionalArgs: ParsedPositionalArgs<TConfig['positionalArgs']>;
|
|
150
150
|
constructor(config: TConfig);
|
|
151
151
|
private printHelp;
|
|
152
|
+
/**
|
|
153
|
+
* Attempts to detect the command used to invoke the currently-running script, for display in the usage line of the help message.
|
|
154
|
+
* Checked in order of most to least reliable signal; falls back to plain `node` if nothing else matches.
|
|
155
|
+
*/
|
|
156
|
+
private static detectRuntimeCommand;
|
|
152
157
|
private static parseStringArg;
|
|
153
158
|
/**
|
|
154
159
|
* Prompts the user for confirmation and returns true if they confirm (y/yes), false otherwise.
|
package/dist/CLI.js
CHANGED
|
@@ -205,7 +205,7 @@ class CLI {
|
|
|
205
205
|
.map((key) => `[--${key} <value>]`)
|
|
206
206
|
.join(' ');
|
|
207
207
|
const flagUsage = [...Object.keys(flags), '--yes', '--no', '--help'].map((key) => `[${key.startsWith('--') ? key : `--${key}`}]`).join(' ');
|
|
208
|
-
console.log(`\nUsage:
|
|
208
|
+
console.log(`\nUsage: ${CLI.detectRuntimeCommand()} ${scriptName} ${flagUsage} ${namedArgUsage} ${positionalUsage}\n`);
|
|
209
209
|
console.log('Flags:');
|
|
210
210
|
for (const [name, spec] of Object.entries(flags)) {
|
|
211
211
|
console.log(` --${name.padEnd(20)} ${spec.description}`);
|
|
@@ -233,6 +233,25 @@ class CLI {
|
|
|
233
233
|
console.log('');
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Attempts to detect the command used to invoke the currently-running script, for display in the usage line of the help message.
|
|
238
|
+
* Checked in order of most to least reliable signal; falls back to plain `node` if nothing else matches.
|
|
239
|
+
*/
|
|
240
|
+
static detectRuntimeCommand() {
|
|
241
|
+
// Bun's own public, documented signal. Cast needed since @types/node's ProcessVersions type has no `bun` key.
|
|
242
|
+
if (process.versions.bun) {
|
|
243
|
+
return 'bun';
|
|
244
|
+
}
|
|
245
|
+
// Internal symbol ts-node sets on `process` when its register hook is active (the same mechanism other tools, e.g. fastify-autoload, rely on to detect ts-node).
|
|
246
|
+
if (Reflect.get(process, Symbol.for('ts-node.register.instance'))) {
|
|
247
|
+
return 'npx ts-node';
|
|
248
|
+
}
|
|
249
|
+
// tsx registers its loader hooks via --require/--import flags pointing into its own package, visible in execArgv regardless of how it was installed.
|
|
250
|
+
if (process.execArgv.some((arg) => arg.includes('tsx/dist/'))) {
|
|
251
|
+
return 'npx tsx';
|
|
252
|
+
}
|
|
253
|
+
return 'node';
|
|
254
|
+
}
|
|
236
255
|
static parseStringArg(rawString, paramName, spec) {
|
|
237
256
|
if ('parse' in spec && !!spec.parse) {
|
|
238
257
|
try {
|
package/dist/esm/CLI.d.ts
CHANGED
|
@@ -149,6 +149,11 @@ declare class CLI<TConfig extends CLIConfig> {
|
|
|
149
149
|
readonly positionalArgs: ParsedPositionalArgs<TConfig['positionalArgs']>;
|
|
150
150
|
constructor(config: TConfig);
|
|
151
151
|
private printHelp;
|
|
152
|
+
/**
|
|
153
|
+
* Attempts to detect the command used to invoke the currently-running script, for display in the usage line of the help message.
|
|
154
|
+
* Checked in order of most to least reliable signal; falls back to plain `node` if nothing else matches.
|
|
155
|
+
*/
|
|
156
|
+
private static detectRuntimeCommand;
|
|
152
157
|
private static parseStringArg;
|
|
153
158
|
/**
|
|
154
159
|
* Prompts the user for confirmation and returns true if they confirm (y/yes), false otherwise.
|
package/dist/esm/CLI.js
CHANGED
|
@@ -167,7 +167,7 @@ class CLI {
|
|
|
167
167
|
.map((key) => `[--${key} <value>]`)
|
|
168
168
|
.join(' ');
|
|
169
169
|
const flagUsage = [...Object.keys(flags), '--yes', '--no', '--help'].map((key) => `[${key.startsWith('--') ? key : `--${key}`}]`).join(' ');
|
|
170
|
-
console.log(`\nUsage:
|
|
170
|
+
console.log(`\nUsage: ${CLI.detectRuntimeCommand()} ${scriptName} ${flagUsage} ${namedArgUsage} ${positionalUsage}\n`);
|
|
171
171
|
console.log('Flags:');
|
|
172
172
|
for (const [name, spec] of Object.entries(flags)) {
|
|
173
173
|
console.log(` --${name.padEnd(20)} ${spec.description}`);
|
|
@@ -195,6 +195,25 @@ class CLI {
|
|
|
195
195
|
console.log('');
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Attempts to detect the command used to invoke the currently-running script, for display in the usage line of the help message.
|
|
200
|
+
* Checked in order of most to least reliable signal; falls back to plain `node` if nothing else matches.
|
|
201
|
+
*/
|
|
202
|
+
static detectRuntimeCommand() {
|
|
203
|
+
// Bun's own public, documented signal. Cast needed since @types/node's ProcessVersions type has no `bun` key.
|
|
204
|
+
if (process.versions.bun) {
|
|
205
|
+
return 'bun';
|
|
206
|
+
}
|
|
207
|
+
// Internal symbol ts-node sets on `process` when its register hook is active (the same mechanism other tools, e.g. fastify-autoload, rely on to detect ts-node).
|
|
208
|
+
if (Reflect.get(process, Symbol.for('ts-node.register.instance'))) {
|
|
209
|
+
return 'npx ts-node';
|
|
210
|
+
}
|
|
211
|
+
// tsx registers its loader hooks via --require/--import flags pointing into its own package, visible in execArgv regardless of how it was installed.
|
|
212
|
+
if (process.execArgv.some((arg) => arg.includes('tsx/dist/'))) {
|
|
213
|
+
return 'npx tsx';
|
|
214
|
+
}
|
|
215
|
+
return 'node';
|
|
216
|
+
}
|
|
198
217
|
static parseStringArg(rawString, paramName, spec) {
|
|
199
218
|
if ('parse' in spec && !!spec.parse) {
|
|
200
219
|
try {
|