fix: support windows absolute extends (#3062)

This commit is contained in:
Pierre Cavin 2023-11-17 03:04:02 +01:00 committed by GitHub
parent 26df1d2aa1
commit 0d06f62411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 13 deletions

View File

@ -1,10 +1,10 @@
import { dirname, extname } from "node:path"; import { dirname } from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { castArray, isNil, isPlainObject, isString, pickBy } from "lodash-es"; import { castArray, isNil, isPlainObject, isString, pickBy } from "lodash-es";
import { readPackageUp } from "read-pkg-up"; import { readPackageUp } from "read-pkg-up";
import { cosmiconfig } from "cosmiconfig"; import { cosmiconfig } from "cosmiconfig";
import resolveFrom from "resolve-from"; import importFrom from "import-from-esm";
import debugConfig from "debug"; import debugConfig from "debug";
import { repoUrl } from "./git.js"; import { repoUrl } from "./git.js";
import PLUGINS_DEFINITIONS from "./definitions/plugins.js"; import PLUGINS_DEFINITIONS from "./definitions/plugins.js";
@ -33,17 +33,7 @@ export default async (context, cliOptions) => {
options = { options = {
...(await castArray(extendPaths).reduce(async (eventualResult, extendPath) => { ...(await castArray(extendPaths).reduce(async (eventualResult, extendPath) => {
const result = await eventualResult; const result = await eventualResult;
const resolvedPath = resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath); const extendsOptions = (await importFrom.silent(__dirname, extendPath)) || (await importFrom(cwd, extendPath));
const importAssertions =
extname(resolvedPath) === ".json"
? {
assert: {
type: "json",
},
}
: undefined;
const { default: extendsOptions } = await import(resolvedPath, importAssertions);
// For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path, // For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path,
// so those plugin will be loaded relative to the config file // so those plugin will be loaded relative to the config file

22
package-lock.json generated
View File

@ -25,6 +25,7 @@
"git-log-parser": "^1.2.0", "git-log-parser": "^1.2.0",
"hook-std": "^3.0.0", "hook-std": "^3.0.0",
"hosted-git-info": "^7.0.0", "hosted-git-info": "^7.0.0",
"import-from-esm": "^1.3.1",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"marked": "^9.0.0", "marked": "^9.0.0",
"marked-terminal": "^6.0.0", "marked-terminal": "^6.0.0",
@ -5926,6 +5927,27 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/import-from-esm": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/import-from-esm/-/import-from-esm-1.3.1.tgz",
"integrity": "sha512-YltaeDglQ6wDZOC8ZAY2I8vK1Ag4XVbs4GhlvNALWz0ee5V+CMkcBhAKbs1iuJZ3fmfgrKFCDRwliM3OxyQMLA==",
"dependencies": {
"debug": "^4.3.4",
"import-meta-resolve": "^4.0.0"
},
"engines": {
"node": ">=16.20"
}
},
"node_modules/import-meta-resolve": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.0.0.tgz",
"integrity": "sha512-okYUR7ZQPH+efeuMJGlq4f8ubUgO50kByRPyt/Cy1Io4PSRsPjxME+YlVaCOx+NIToW7hCsZNFJyTPFFKepRSA==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/imurmurhash": { "node_modules/imurmurhash": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",

View File

@ -43,6 +43,7 @@
"git-log-parser": "^1.2.0", "git-log-parser": "^1.2.0",
"hook-std": "^3.0.0", "hook-std": "^3.0.0",
"hosted-git-info": "^7.0.0", "hosted-git-info": "^7.0.0",
"import-from-esm": "^1.3.1",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"marked": "^9.0.0", "marked": "^9.0.0",
"marked-terminal": "^6.0.0", "marked-terminal": "^6.0.0",