@commitlint/load 18.4.0 → 18.4.2
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Options } from 'cosmiconfig';
|
|
2
1
|
export interface LoadConfigResult {
|
|
3
2
|
config: unknown;
|
|
4
3
|
filepath: string;
|
|
@@ -6,5 +5,5 @@ export interface LoadConfigResult {
|
|
|
6
5
|
}
|
|
7
6
|
export declare function loadConfig(cwd: string, configPath?: string): Promise<LoadConfigResult | null>;
|
|
8
7
|
export declare const isDynamicAwaitSupported: () => boolean;
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const isEsmModule: (cwd: string) => boolean;
|
|
10
9
|
//# sourceMappingURL=load-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAID,wBAAsB,UAAU,CAC/B,GAAG,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAwDlC;AAKD,eAAO,MAAM,uBAAuB,eAOnC,CAAC;AAGF,eAAO,MAAM,WAAW,QAAS,MAAM,YAStC,CAAC"}
|
package/lib/utils/load-config.js
CHANGED
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.isEsmModule = exports.isDynamicAwaitSupported = exports.loadConfig = void 0;
|
|
7
7
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
8
8
|
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
9
|
+
const fs_1 = require("fs");
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
10
11
|
const moduleName = 'commitlint';
|
|
11
12
|
async function loadConfig(cwd, configPath) {
|
|
@@ -16,7 +17,11 @@ async function loadConfig(cwd, configPath) {
|
|
|
16
17
|
}
|
|
17
18
|
return tsLoaderInstance(...args);
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
+
// If dynamic await is supported (Node >= v20.8.0) or directory uses ESM, support
|
|
21
|
+
// async js/cjs loaders (dynamic import). Otherwise, use synchronous js/cjs loaders.
|
|
22
|
+
const loaders = (0, exports.isDynamicAwaitSupported)() || (0, exports.isEsmModule)(cwd)
|
|
23
|
+
? cosmiconfig_1.defaultLoaders
|
|
24
|
+
: cosmiconfig_1.defaultLoadersSync;
|
|
20
25
|
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
21
26
|
searchPlaces: [
|
|
22
27
|
// cosmiconfig overrides default searchPlaces if any new search place is added (For e.g. `*.ts` files),
|
|
@@ -28,16 +33,22 @@ async function loadConfig(cwd, configPath) {
|
|
|
28
33
|
`.${moduleName}rc.yml`,
|
|
29
34
|
`.${moduleName}rc.js`,
|
|
30
35
|
`.${moduleName}rc.cjs`,
|
|
36
|
+
`.${moduleName}rc.mjs`,
|
|
31
37
|
`${moduleName}.config.js`,
|
|
32
38
|
`${moduleName}.config.cjs`,
|
|
39
|
+
`${moduleName}.config.mjs`,
|
|
33
40
|
// files supported by TypescriptLoader
|
|
34
41
|
`.${moduleName}rc.ts`,
|
|
35
42
|
`.${moduleName}rc.cts`,
|
|
36
43
|
`${moduleName}.config.ts`,
|
|
37
44
|
`${moduleName}.config.cts`,
|
|
38
|
-
...(searchPlaces || []),
|
|
39
45
|
],
|
|
40
|
-
loaders:
|
|
46
|
+
loaders: {
|
|
47
|
+
'.ts': tsLoader,
|
|
48
|
+
'.cts': tsLoader,
|
|
49
|
+
'.cjs': loaders['.cjs'],
|
|
50
|
+
'.js': loaders['.js'],
|
|
51
|
+
},
|
|
41
52
|
});
|
|
42
53
|
const explicitPath = configPath ? path_1.default.resolve(cwd, configPath) : undefined;
|
|
43
54
|
const explore = explicitPath ? explorer.load : explorer.search;
|
|
@@ -49,7 +60,7 @@ async function loadConfig(cwd, configPath) {
|
|
|
49
60
|
return null;
|
|
50
61
|
}
|
|
51
62
|
exports.loadConfig = loadConfig;
|
|
52
|
-
// See the following issues for more context:
|
|
63
|
+
// See the following issues for more context, contributing to failing Jest tests:
|
|
53
64
|
// - Issue: https://github.com/nodejs/node/issues/40058
|
|
54
65
|
// - Resolution: https://github.com/nodejs/node/pull/48510 (Node v20.8.0)
|
|
55
66
|
const isDynamicAwaitSupported = () => {
|
|
@@ -60,19 +71,15 @@ const isDynamicAwaitSupported = () => {
|
|
|
60
71
|
return major >= 20 && minor >= 8;
|
|
61
72
|
};
|
|
62
73
|
exports.isDynamicAwaitSupported = isDynamicAwaitSupported;
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
// Is the given directory set up to use ESM (ECMAScript Modules)?
|
|
75
|
+
const isEsmModule = (cwd) => {
|
|
76
|
+
var _a;
|
|
77
|
+
const packagePath = path_1.default.join(cwd, 'package.json');
|
|
78
|
+
if (!(0, fs_1.existsSync)(packagePath)) {
|
|
79
|
+
return false;
|
|
69
80
|
}
|
|
70
|
-
:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'.js': cosmiconfig_1.defaultLoadersSync['.js'],
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
exports.getDynamicAwaitConfig = getDynamicAwaitConfig;
|
|
81
|
+
const packageJSON = (0, fs_1.readFileSync)(packagePath, { encoding: 'utf-8' });
|
|
82
|
+
return ((_a = JSON.parse(packageJSON)) === null || _a === void 0 ? void 0 : _a.type) === 'module';
|
|
83
|
+
};
|
|
84
|
+
exports.isEsmModule = isEsmModule;
|
|
78
85
|
//# sourceMappingURL=load-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":";;;;;;AAAA,6CAKqB;AACrB,iFAA+D;AAC/D,gDAAwB;AAQxB,MAAM,UAAU,GAAG,YAAY,CAAC;AAEzB,KAAK,UAAU,UAAU,CAC/B,GAAW,EACX,UAAmB;IAEnB,IAAI,gBAAoC,CAAC;IACzC,MAAM,QAAQ,GAAW,CAAC,GAAG,IAAI,EAAE,EAAE;QACpC,IAAI,CAAC,gBAAgB,EAAE;YACtB,gBAAgB,GAAG,IAAA,gDAAgB,GAAE,CAAC;SACtC;QACD,OAAO,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;IAEF,MAAM,
|
|
1
|
+
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":";;;;;;AAAA,6CAKqB;AACrB,iFAA+D;AAC/D,2BAA4C;AAC5C,gDAAwB;AAQxB,MAAM,UAAU,GAAG,YAAY,CAAC;AAEzB,KAAK,UAAU,UAAU,CAC/B,GAAW,EACX,UAAmB;IAEnB,IAAI,gBAAoC,CAAC;IACzC,MAAM,QAAQ,GAAW,CAAC,GAAG,IAAI,EAAE,EAAE;QACpC,IAAI,CAAC,gBAAgB,EAAE;YACtB,gBAAgB,GAAG,IAAA,gDAAgB,GAAE,CAAC;SACtC;QACD,OAAO,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;IAEF,iFAAiF;IACjF,oFAAoF;IACpF,MAAM,OAAO,GACZ,IAAA,+BAAuB,GAAE,IAAI,IAAA,mBAAW,EAAC,GAAG,CAAC;Q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A0E;AACnE,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC3C,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO;SACpC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;SAChB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9B,OAAO,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC;AAPW,QAAA,uBAAuB,2BAOlC;AAEF,iEAAiE;AAC1D,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE;;IAC1C,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAEnD,IAAI,CAAC,IAAA,eAAU,EAAC,WAAW,CAAC,EAAE;QAC7B,OAAO,KAAK,CAAC;KACb;IAED,MAAM,WAAW,GAAG,IAAA,iBAAY,EAAC,WAAW,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC;IACnE,OAAO,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,0CAAE,IAAI,MAAK,QAAQ,CAAC;AACnD,CAAC,CAAC;AATW,QAAA,WAAW,eAStB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/load",
|
|
3
|
-
"version": "18.4.
|
|
3
|
+
"version": "18.4.2",
|
|
4
4
|
"description": "Load shared commitlint configuration",
|
|
5
5
|
"main": "lib/load.js",
|
|
6
6
|
"types": "lib/load.d.ts",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"@commitlint/types": "^18.4.0",
|
|
51
51
|
"@types/node": "^18.11.9",
|
|
52
52
|
"chalk": "^4.1.0",
|
|
53
|
-
"cosmiconfig": "^8.
|
|
53
|
+
"cosmiconfig": "^8.3.6",
|
|
54
54
|
"cosmiconfig-typescript-loader": "^5.0.0",
|
|
55
55
|
"lodash.isplainobject": "^4.0.6",
|
|
56
56
|
"lodash.merge": "^4.6.2",
|
|
57
57
|
"lodash.uniq": "^4.5.0",
|
|
58
58
|
"resolve-from": "^5.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0370a855dcc026dda4dd29122f49ed7db5657de3"
|
|
61
61
|
}
|