1
1
/*
2
2
This script prepares the central `build` directory for NPM package creation.
3
- It first copies all non-code files into the `build` directory, including `package.json` which
4
- is edited to adjust entry point paths. These corrections are performed so that they align with
3
+ It first copies all non-code files into the `build` directory, including `package.json`, which
4
+ is edited to adjust entry point paths. These corrections are performed so that the paths align with
5
5
the directory structure inside `build`.
6
6
*/
7
7
@@ -13,7 +13,7 @@ const BUILD_DIR = 'build';
13
13
const ASSETS = [ 'README.md' , 'LICENSE' , 'package.json' , '.npmignore' ] ;
14
14
const ENTRY_POINTS = [ 'main' , 'module' , 'types' ] ;
15
15
16
- // check if build dirs exists
16
+ // check if build dir exists
17
17
if ( ! fs . existsSync ( BUILD_DIR ) ) {
18
18
console . error ( `Directory ${ BUILD_DIR } DOES NOT exist` ) ;
19
19
console . error ( "This script should only be executed after you've run `yarn build`." ) ;
@@ -33,7 +33,7 @@ ASSETS.forEach(asset => {
33
33
const packageJsonPath = path . join ( process . cwd ( ) , BUILD_DIR , 'package.json' ) ;
34
34
const pkg : { [ key : string ] : string } = require ( packageJsonPath ) ;
35
35
36
- // modify entry points to point to correct paths (i.e. delete the build directory)
36
+ // modify entry points to point to correct paths (i.e. strip out the build directory)
37
37
ENTRY_POINTS . filter ( entryPoint => ! ! pkg [ entryPoint ] ) . forEach ( entryPoint => {
38
38
pkg [ entryPoint ] = pkg [ entryPoint ] . replace ( `${ BUILD_DIR } /` , '' ) ;
39
39
} ) ;
@@ -45,4 +45,4 @@ delete pkg.volta;
45
45
// write modified package.json to file
46
46
fs . writeFileSync ( packageJsonPath , JSON . stringify ( pkg , null , 2 ) ) ;
47
47
48
- console . log ( 'Successfully finished postbuild commands' ) ;
48
+ console . log ( `\nSuccessfully finished postbuild commands for ${ pkg . name } ` ) ;
0 commit comments