1- #!/usr/bin/env node
2-
3- console . log ( 'running better-npm-run in' , process . cwd ( ) ) ;
4- var join = require ( 'path' ) . join ;
5- var fullPackagePath = join ( process . cwd ( ) , 'package.json' ) ;
6- var pkg = require ( fullPackagePath ) ;
7- var exec = require ( './lib/exec.js' )
8-
9- if ( ! pkg . scripts ) {
10- process . stderr . write ( 'ERROR: No scripts found!' ) ;
11- process . exit ( 1 ) ;
12- }
13- if ( ! pkg . betterScripts ) {
14- process . stderr . write ( 'ERROR: No betterScripts found!' ) ;
15- process . exit ( 1 ) ;
16- }
17- if ( ! process . argv [ 2 ] ) {
18- process . stderr . write ( 'ERROR: No script name provided!' ) ;
19- process . exit ( 1 ) ;
20- }
21- if ( ! pkg . betterScripts [ process . argv [ 2 ] ] ) {
22- process . stderr . write ( 'ERROR: No betterScript with name "' + process . argv [ 2 ] + '" was found!' ) ;
23- process . exit ( 1 ) ;
24- }
25-
26- console . log ( 'Executing script: ' + process . argv [ 2 ] + '\n' ) ;
27-
28- exec ( pkg . betterScripts [ process . argv [ 2 ] ] ) ;
1+ #!/usr/bin/env node
2+
3+ console . log ( 'running better-npm-run in' , process . cwd ( ) ) ;
4+ var join = require ( 'path' ) . join ;
5+ var fullPackagePath = join ( process . cwd ( ) , 'package.json' ) ;
6+ var pkg = require ( fullPackagePath ) ;
7+ var exec = require ( './lib/exec.js' )
8+
9+ if ( ! pkg . scripts ) {
10+ process . stderr . write ( 'ERROR: No scripts found!' ) ;
11+ process . exit ( 1 ) ;
12+ }
13+ if ( ! pkg . betterScripts ) {
14+ process . stderr . write ( 'ERROR: No betterScripts found!' ) ;
15+ process . exit ( 1 ) ;
16+ }
17+ if ( ! process . argv [ 2 ] ) {
18+ process . stderr . write ( 'ERROR: No script name provided!' ) ;
19+ process . exit ( 1 ) ;
20+ }
21+ if ( ! pkg . betterScripts [ process . argv [ 2 ] ] ) {
22+ process . stderr . write ( 'ERROR: No betterScript with name "' + process . argv [ 2 ] + '" was found!' ) ;
23+ process . exit ( 1 ) ;
24+ }
25+
26+ console . log ( 'Executing script: ' + process . argv [ 2 ] + '\n' ) ;
27+
28+ exec ( pkg . betterScripts [ process . argv [ 2 ] ] , function ( error , stdout , stderr ) {
29+ process . stderr . write ( stderr ) ;
30+ process . stdout . write ( stdout ) ;
31+ if ( error !== null ) {
32+ console . log ( 'exec error: ' + error ) ;
33+ }
34+ } ) ;
0 commit comments