File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 3131 "build" : " scripts/preinstall && scripts/build" ,
3232 "install" : " prebuild-install --download https://github.com/NodeOS/nodeos-cross-toolchain/releases/download/v{version}/{platform}-{arch}.tar.gz || npm run build" ,
3333 "postinstall" : " scripts/postinstall" ,
34- "prepublish" : " rm -rf bin/*-nodeos-linux-musl-* && truncate --size 0 bin/* " ,
34+ "prepublish" : " scripts/prepublish " ,
3535 "test" : " scripts/test" ,
3636 "unbuild" : " scripts/unbuild"
3737 },
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const fs = require ( 'fs' )
4+
5+
6+ const DIR = 'bin'
7+
8+ const bins = Object . keys ( require ( '../package.json' ) . bin )
9+
10+
11+ // http://stackoverflow.com/a/34597104/586382
12+ // NPM will run prepublish script after `npm install` (https://docs.npmjs.com/misc/scripts)
13+ // This ensures that when script is executed using `npm *` it is run only when the command is `npm publish`.
14+ const npm_config_argv = process . env . npm_config_argv
15+ if ( npm_config_argv && JSON . parse ( npm_config_argv ) . original [ 0 ] === 'publish' )
16+ fs . readdir ( DIR , function ( err , files )
17+ {
18+ if ( err ) throw err
19+
20+ // Delete all files in the `bin` folder
21+ files . forEach ( function ( file )
22+ {
23+ fs . unlinkSync ( DIR + '/' + file )
24+ } )
25+
26+ // Re-create the symlinks stubs
27+ bins . forEach ( function ( file )
28+ {
29+ fs . writeFileSync ( DIR + '/' + file , '' )
30+ } )
31+ } )
You can’t perform that action at this time.
0 commit comments