Skip to content

Commit 4871fa4

Browse files
committed
fix generate-helpers failing in URL-encoded path
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.
1 parent 08772e2 commit 4871fa4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/babel-helpers/scripts/generate-helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "fs";
22
import { join } from "path";
3-
import { URL } from "url";
3+
import { URL, fileURLToPath } from "url";
44

55
const HELPERS_FOLDER = new URL("../src/helpers", import.meta.url);
66
const IGNORED_FILES = new Set(["package.json"]);
@@ -23,7 +23,7 @@ import template from "@babel/template";
2323
const varName = isValidId ? helperName : `_${helperName}`;
2424

2525
const fileContents = await fs.promises.readFile(
26-
join(HELPERS_FOLDER.pathname, file),
26+
join(fileURLToPath(HELPERS_FOLDER), file),
2727
"utf8"
2828
);
2929
const { minVersion } = fileContents.match(

0 commit comments

Comments
 (0)