Skip to content

Commit c0cf355

Browse files
committed
apply review suggestions
1 parent 356775d commit c0cf355

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/gatsby/scripts/prepack.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ import * as path from 'path';
88

99
const PACKAGE_ASSETS = ['gatsby-browser.js', 'gatsby-node.js'];
1010

11-
export function prepack(buildDir: string): void {
11+
export function prepack(buildDir: string): boolean {
1212
// copy package-specific assets to build dir
13-
PACKAGE_ASSETS.forEach(asset => {
13+
return PACKAGE_ASSETS.every(asset => {
1414
const assetPath = path.resolve(asset);
1515
try {
1616
if (!fs.existsSync(assetPath)) {
1717
console.error(`Asset ${asset} does not exist.`);
18-
process.exit(1);
18+
return false;
1919
}
2020
fs.copyFileSync(assetPath, path.resolve(buildDir, asset));
2121
} catch (error) {
2222
console.error(`Error while copying ${asset} to ${buildDir}`);
23-
process.exit(1);
23+
return false;
2424
}
25+
return true;
2526
});
2627
}

scripts/prepack.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ try {
9191
async function runPackagePrepack(packagePrepackPath: string): Promise<void> {
9292
const { prepack } = await import(packagePrepackPath);
9393
if (prepack && typeof prepack === 'function') {
94-
prepack(buildDir);
94+
const success = prepack(buildDir);
95+
if (!success) {
96+
process.exit(1);
97+
}
9598
}
9699
}
97100

0 commit comments

Comments
 (0)