Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6cd638e

Browse files
fix: make asinit exit if package.json has a "type" not equal to "module" (#2938)
1 parent 69cc1cb commit 6cd638e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎bin/asinit.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,23 @@ const paths = [
115115
[gitignoreFile, "Git configuration that excludes compiled binaries from source control."],
116116
[asconfigFile, "Configuration file defining both a 'debug' and a 'release' target."],
117117
[packageFile, "Package info containing the necessary commands to compile to WebAssembly."],
118-
[testsIndexFile, "Stater test to check that the module is functioning."],
118+
[testsIndexFile, "Starter test to check that the module is functioning."],
119119
[indexHtmlFile, "Starter HTML file that loads the module in a browser."]
120120
];
121121

122122
const formatPath = filePath => "./" + path.relative(projectDir, filePath).replace(/\\/g, "/");
123123

124+
if (fs.existsSync(packageFile)) {
125+
const pkg = JSON.parse(fs.readFileSync(packageFile));
126+
if ("type" in pkg && pkg["type"] !== "module") {
127+
console.error(stdoutColors.red([
128+
`Error: The "type" field in ${formatPath(packageFile)} is set to "${pkg["type"]}".`,
129+
` asinit requires the "type" field to be set to "module" (ES modules).`
130+
].join("\n")));
131+
process.exit(1);
132+
}
133+
}
134+
124135
console.log([
125136
"Version: " + version,
126137
"",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /