Skip to content

Commit 312036d

Browse files
committed
use path.resolve() instead of path.join()
1 parent d66c3d4 commit 312036d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/postbuild.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@ const ASSETS = ['README.md', 'LICENSE', 'package.json', '.npmignore'];
1414
const ENTRY_POINTS = ['main', 'module', 'types'];
1515

1616
// check if build dir exists
17-
if (!fs.existsSync(BUILD_DIR)) {
17+
if (!fs.existsSync(path.resolve(BUILD_DIR))) {
1818
console.error(`Directory ${BUILD_DIR} DOES NOT exist`);
1919
console.error("This script should only be executed after you've run `yarn build`.");
2020
process.exit(1);
2121
}
2222

2323
// copy non-code assets to build dir
2424
ASSETS.forEach(asset => {
25-
if (!fs.existsSync(asset)) {
25+
const assetPath = path.resolve(asset);
26+
if (!fs.existsSync(assetPath)) {
2627
console.error(`Asset ${asset} does not exist.`);
2728
process.exit(1);
2829
}
29-
fs.copyFileSync(asset, path.join(BUILD_DIR, asset));
30+
fs.copyFileSync(assetPath, path.resolve(BUILD_DIR, asset));
3031
});
3132

3233
// package.json modifications
33-
const packageJsonPath = path.join(process.cwd(), BUILD_DIR, 'package.json');
34+
const packageJsonPath = path.resolve(BUILD_DIR, 'package.json');
3435
const pkgJson: { [key: string]: string } = require(packageJsonPath);
3536

3637
// modify entry points to point to correct paths (i.e. strip out the build directory)

0 commit comments

Comments
 (0)