@oclif/core 3.10.0 → 3.10.1
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/config/ts-node.js +8 -15
- package/lib/util/fs.d.ts +1 -0
- package/lib/util/fs.js +8 -1
- package/package.json +1 -1
package/lib/config/ts-node.js
CHANGED
|
@@ -15,28 +15,21 @@ const util_2 = require("./util");
|
|
|
15
15
|
const debug = (0, util_2.Debug)('ts-node');
|
|
16
16
|
exports.TS_CONFIGS = {};
|
|
17
17
|
const REGISTERED = new Set();
|
|
18
|
+
function isErrno(error) {
|
|
19
|
+
return 'code' in error && error.code === 'ENOENT';
|
|
20
|
+
}
|
|
18
21
|
async function loadTSConfig(root) {
|
|
19
22
|
try {
|
|
20
23
|
if (exports.TS_CONFIGS[root])
|
|
21
24
|
return exports.TS_CONFIGS[root];
|
|
22
|
-
|
|
23
|
-
const tsconfig = await (0, fs_1.readJson)(tsconfigPath);
|
|
24
|
-
if (!tsconfig || Object.keys(tsconfig.compilerOptions).length === 0)
|
|
25
|
-
return;
|
|
26
|
-
exports.TS_CONFIGS[root] = tsconfig;
|
|
27
|
-
if (tsconfig.extends) {
|
|
28
|
-
const { parse } = await import('tsconfck');
|
|
29
|
-
const result = await parse(tsconfigPath);
|
|
30
|
-
const tsNodeOpts = Object.fromEntries((result.extended ?? []).flatMap((e) => Object.entries(e.tsconfig['ts-node'] ?? {})).reverse());
|
|
31
|
-
exports.TS_CONFIGS[root] = { ...result.tsconfig, 'ts-node': tsNodeOpts };
|
|
32
|
-
}
|
|
25
|
+
exports.TS_CONFIGS[root] = await (0, fs_1.readTSConfig)((0, node_path_1.join)(root, 'tsconfig.json'));
|
|
33
26
|
return exports.TS_CONFIGS[root];
|
|
34
27
|
}
|
|
35
28
|
catch (error) {
|
|
36
|
-
if (error
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
29
|
+
if (isErrno(error))
|
|
30
|
+
return;
|
|
31
|
+
debug(`Could not parse tsconfig.json. Skipping ts-node registration for ${root}.`);
|
|
32
|
+
(0, errors_1.memoizedWarn)(`Could not parse tsconfig.json for ${root}. Falling back to compiled source.`);
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
35
|
async function registerTSNode(root) {
|
package/lib/util/fs.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export declare function readJsonSync(path: string, parse: false): string;
|
|
|
18
18
|
export declare function readJsonSync<T = unknown>(path: string, parse?: true): T;
|
|
19
19
|
export declare function safeReadJson<T>(path: string): Promise<T | undefined>;
|
|
20
20
|
export declare function existsSync(path: string): boolean;
|
|
21
|
+
export declare function readTSConfig(path: string): Promise<any>;
|
package/lib/util/fs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.existsSync = exports.safeReadJson = exports.readJsonSync = exports.readJson = exports.fileExists = exports.dirExists = exports.requireJson = void 0;
|
|
3
|
+
exports.readTSConfig = exports.existsSync = exports.safeReadJson = exports.readJsonSync = exports.readJson = exports.fileExists = exports.dirExists = exports.requireJson = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const promises_1 = require("node:fs/promises");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
@@ -69,3 +69,10 @@ function existsSync(path) {
|
|
|
69
69
|
return (0, node_fs_1.existsSync)(path);
|
|
70
70
|
}
|
|
71
71
|
exports.existsSync = existsSync;
|
|
72
|
+
async function readTSConfig(path) {
|
|
73
|
+
const { parse } = await import('tsconfck');
|
|
74
|
+
const result = await parse(path);
|
|
75
|
+
const tsNodeOpts = Object.fromEntries((result.extended ?? []).flatMap((e) => Object.entries(e.tsconfig['ts-node'] ?? {})).reverse());
|
|
76
|
+
return { ...result.tsconfig, 'ts-node': tsNodeOpts };
|
|
77
|
+
}
|
|
78
|
+
exports.readTSConfig = readTSConfig;
|