fix generate-helpers failing in URL-encoded path (#13404)
HELPERS_FOLDER.pathname may be URL-encoded, if the working tree's absolute path contains spaces, some reserved characters, or anything beyond ASCII. readFile accepts a plain String or URL for the path, but does not automatically decode URL-encoded Strings.
This commit is contained in:
parent
08772e28f2
commit
b397aca024
@ -1,6 +1,6 @@
|
||||
import fs from "fs";
|
||||
import { join } from "path";
|
||||
import { URL } from "url";
|
||||
import { URL, fileURLToPath } from "url";
|
||||
|
||||
const HELPERS_FOLDER = new URL("../src/helpers", import.meta.url);
|
||||
const IGNORED_FILES = new Set(["package.json"]);
|
||||
@ -23,7 +23,7 @@ import template from "@babel/template";
|
||||
const varName = isValidId ? helperName : `_${helperName}`;
|
||||
|
||||
const fileContents = await fs.promises.readFile(
|
||||
join(HELPERS_FOLDER.pathname, file),
|
||||
join(fileURLToPath(HELPERS_FOLDER), file),
|
||||
"utf8"
|
||||
);
|
||||
const { minVersion } = fileContents.match(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user