@@ -32,12 +32,12 @@ const PRETTIER_PATHS = [
3232] . join ( ' ' ) ;
3333
3434const task = process . argv [ 2 ] ;
35- const args = process . argv . slice ( 3 ) . join ( ' ' ) ;
35+ const taskArgs = process . argv . slice ( 3 ) . join ( ' ' ) ;
3636
3737void run ( ) ;
3838
3939async function run ( ) {
40- logInfo ( args ? `[args:"${ args } "]` : '' ) ;
40+ logInfo ( taskArgs ? `[args:"${ taskArgs } "]` : '' ) ;
4141
4242 switch ( task ) {
4343 // As per NPM documentation (https://docs.npmjs.com/cli/v9/using-npm/scripts)
@@ -89,7 +89,7 @@ async function run() {
8989 }
9090
9191 case 'coverage' : {
92- executeCmd ( `jest --coverage ${ args } ` ) ;
92+ executeCmd ( `jest --coverage ${ taskArgs } ` ) ;
9393 executeCmd ( 'open-cli coverage/lcov-report/index.html' ) ;
9494
9595 break ;
@@ -107,7 +107,7 @@ async function run() {
107107 executeCmd ( `git tag -a ${ PKG . version } -m '${ PKG . version } '` ) ;
108108 executeCmd ( `git push origin ${ RELEASE_BRANCH } ` ) ;
109109 executeCmd ( `git push origin '${ PKG . version } '` ) ;
110- executeCmd ( 'npm publish' ) ;
110+ executeInteractiveCmd ( 'npm publish' ) ;
111111
112112 break ;
113113 }
@@ -140,15 +140,15 @@ function buildTypescript({ force }) {
140140 deleteLib ( ) ;
141141
142142 // Generate .js CommonJS code and .d.ts TypeScript declaration files in lib/.
143- executeCmd ( `tsc ${ args } ` ) ;
143+ executeCmd ( `tsc ${ taskArgs } ` ) ;
144144}
145145
146146function watchTypescript ( ) {
147147 logInfo ( 'watchTypescript()' ) ;
148148
149149 deleteLib ( ) ;
150150
151- executeCmd ( `tsc --watch ${ args } ` ) ;
151+ executeCmd ( `tsc --watch ${ taskArgs } ` ) ;
152152}
153153
154154function lint ( ) {
@@ -174,7 +174,7 @@ function format() {
174174function test ( ) {
175175 logInfo ( 'test()' ) ;
176176
177- executeCmd ( `jest --silent false --detectOpenHandles ${ args } ` ) ;
177+ executeCmd ( `jest --silent false --detectOpenHandles ${ taskArgs } ` ) ;
178178}
179179
180180function installDeps ( ) {
@@ -211,20 +211,32 @@ function executeCmd(command) {
211211 }
212212}
213213
214- function logInfo ( message ) {
214+ function executeInteractiveCmd ( command ) {
215+ logInfo ( `executeInteractiveCmd(): ${ command } ` ) ;
216+
217+ try {
218+ execSync ( command , { stdio : 'inherit' , env : process . env } ) ;
219+ } catch ( error ) {
220+ logError ( `executeInteractiveCmd() failed, exiting: ${ error } ` ) ;
221+
222+ exitWithError ( ) ;
223+ }
224+ }
225+
226+ function logInfo ( ...args ) {
215227 // eslint-disable-next-line no-console
216- console . log ( `npm-scripts \x1b[36m[INFO] [${ task } ]\x1b[0m` , message ) ;
228+ console . log ( `npm-scripts.mjs \x1b[36m[INFO] [${ task } ]\x1b[0m` , ... args ) ;
217229}
218230
219231// eslint-disable-next-line no-unused-vars
220- function logWarn ( message ) {
232+ function logWarn ( ... args ) {
221233 // eslint-disable-next-line no-console
222- console . warn ( `npm-scripts \x1b[33m[WARN] [${ task } ]\x1b[ 0m` , message ) ;
234+ console . warn ( `npm-scripts.mjs \x1b[33m[WARN] [${ task } ]\x1b\ 0m` , ... args ) ;
223235}
224236
225- function logError ( message ) {
237+ function logError ( ... args ) {
226238 // eslint-disable-next-line no-console
227- console . error ( `npm-scripts \x1b[31m[ERROR] [${ task } ]\x1b[0m` , message ) ;
239+ console . error ( `npm-scripts.mjs \x1b[31m[ERROR] [${ task } ]\x1b[0m` , ... args ) ;
228240}
229241
230242function exitWithError ( ) {
0 commit comments