Skip to content

Commit 686644a

Browse files
committed
apply suggestions from code review
1 parent 38969e2 commit 686644a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/postbuild.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ try {
2222
}
2323
} catch (error) {
2424
console.error(`Error while looking up directory ${BUILD_DIR}`);
25+
process.exit(1);
2526
}
2627

2728
// copy non-code assets to build dir
@@ -35,19 +36,19 @@ ASSETS.forEach(asset => {
3536
fs.copyFileSync(assetPath, path.resolve(BUILD_DIR, asset));
3637
} catch (error) {
3738
console.error(`Error while copying ${asset} to ${BUILD_DIR}`);
39+
process.exit(1);
3840
}
3941
});
4042

4143
// package.json modifications
4244
const packageJsonPath = path.resolve(BUILD_DIR, 'package.json');
43-
const pkgJson: { [key: string]: string } = require(packageJsonPath);
45+
const pkgJson: { [key: string]: unknown } = require(packageJsonPath);
4446

4547
// modify entry points to point to correct paths (i.e. strip out the build directory)
4648
ENTRY_POINTS.filter(entryPoint => pkgJson[entryPoint]).forEach(entryPoint => {
47-
pkgJson[entryPoint] = pkgJson[entryPoint].replace(`${BUILD_DIR}/`, '');
49+
pkgJson[entryPoint] = (pkgJson[entryPoint] as string).replace(`${BUILD_DIR}/`, '');
4850
});
4951

50-
// TODO decide if we want this:
5152
delete pkgJson.scripts;
5253
delete pkgJson.volta;
5354

@@ -56,6 +57,7 @@ try {
5657
fs.writeFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2));
5758
} catch (error) {
5859
console.error(`Error while writing package.json to disk`);
60+
process.exit(1);
5961
}
6062

6163
console.log(`\nSuccessfully finished postbuild commands for ${pkgJson.name}`);

0 commit comments

Comments
 (0)