Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor improvement to gulp generate-runtime-helpers error message #13522

Merged
merged 2 commits into from Jul 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions packages/babel-helpers/scripts/generate-helpers.js
Expand Up @@ -17,18 +17,21 @@ import template from "@babel/template";

for (const file of (await fs.promises.readdir(HELPERS_FOLDER)).sort()) {
if (IGNORED_FILES.has(file)) continue;
if (file.startsWith(".")) continue; // ignore e.g. vim swap files

const [helperName] = file.split(".");
const isValidId = isValidBindingIdentifier(helperName);
const varName = isValidId ? helperName : `_${helperName}`;

const fileContents = await fs.promises.readFile(
join(fileURLToPath(HELPERS_FOLDER), file),
"utf8"
);
const { minVersion } = fileContents.match(
const filePath = join(fileURLToPath(HELPERS_FOLDER), file);
const fileContents = await fs.promises.readFile(filePath, "utf8");
const minVersionMatch = fileContents.match(
/^\s*\/\*\s*@minVersion\s+(?<minVersion>\S+)\s*\*\/\s*$/m
).groups;
);
if (!minVersionMatch) {
throw new Error(`@minVersion number missing in ${filePath}`);
}
const { minVersion } = minVersionMatch.groups;

// TODO: We can minify the helpers in production
const source = fileContents
Expand Down