@oclif/core 5.0.0 → 5.1.0
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/lib/help/index.js +21 -2
- package/lib/parser/parse.js +1 -1
- package/package.json +1 -1
package/lib/help/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Help = exports.HelpBase = exports.standardizeIDFromArgv = exports.normalizeArgv = exports.getHelpFlagAdditions = exports.HelpFormatter = exports.CommandHelp = void 0;
|
|
7
7
|
exports.loadHelpClass = loadHelpClass;
|
|
8
8
|
const ansis_1 = __importDefault(require("ansis"));
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
9
10
|
const ts_path_1 = require("../config/ts-path");
|
|
10
11
|
const error_1 = require("../errors/error");
|
|
11
12
|
const module_loader_1 = require("../module-loader");
|
|
@@ -331,11 +332,29 @@ function determineLocation(helpClass) {
|
|
|
331
332
|
async function loadHelpClass(config) {
|
|
332
333
|
if (config.pjson.oclif?.helpClass) {
|
|
333
334
|
const { identifier, target } = determineLocation(config.pjson.oclif?.helpClass);
|
|
334
|
-
|
|
335
|
-
const path = (await (0, ts_path_1.tsPath)(config.root, target)) ?? target;
|
|
335
|
+
const loadClass = async (path) => {
|
|
336
336
|
const module = await (0, module_loader_1.load)(config, path);
|
|
337
337
|
const helpClass = module[identifier] ?? (identifier === 'default' ? extractClass(module) : undefined);
|
|
338
338
|
return extractClass(helpClass);
|
|
339
|
+
};
|
|
340
|
+
// The compiled artifact that `helpClass` points at (e.g. "./dist/help/myHelp.js").
|
|
341
|
+
const compiledPath = (0, node_path_1.isAbsolute)(target) ? target : (0, node_path_1.join)(config.root, target);
|
|
342
|
+
try {
|
|
343
|
+
// `tsPath` may rewrite the compiled path to the TypeScript source for local
|
|
344
|
+
// development. That source can be unloadable in some runtimes — e.g. an ESM
|
|
345
|
+
// CLI executed under plain `node` without `tsx` registered, where the `.js`
|
|
346
|
+
// specifiers in the source can't be resolved to their `.ts` siblings.
|
|
347
|
+
const path = (await (0, ts_path_1.tsPath)(config.root, target)) ?? target;
|
|
348
|
+
try {
|
|
349
|
+
return await loadClass(path);
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
// If we tried (and failed) to load transpiled source, fall back to the
|
|
353
|
+
// configured compiled artifact before giving up.
|
|
354
|
+
if (path === compiledPath)
|
|
355
|
+
throw error;
|
|
356
|
+
return await loadClass(compiledPath);
|
|
357
|
+
}
|
|
339
358
|
}
|
|
340
359
|
catch (error) {
|
|
341
360
|
throw new Error(`Unable to load configured help class "${target}", failed with message:\n${error.message}`);
|
package/lib/parser/parse.js
CHANGED
|
@@ -42,7 +42,7 @@ const readStdin = async () => {
|
|
|
42
42
|
const lines = [];
|
|
43
43
|
const ac = new AbortController();
|
|
44
44
|
const { signal } = ac;
|
|
45
|
-
const timeout = setTimeout(() => ac.abort(), 10);
|
|
45
|
+
const timeout = setTimeout(() => ac.abort(), Number(process.env.OCLIF_STDIN_TIMEOUT_MS) || 10);
|
|
46
46
|
const rl = (0, node_readline_1.createInterface)({
|
|
47
47
|
input: stdin,
|
|
48
48
|
output: stdout,
|