11"use strict" ;
22
33const SemVer = require ( "semver" ) ;
4- const spawnSync = require ( "cross -spawn" ) . sync ;
4+ const ezSpawn = require ( "ez -spawn" ) ;
55const fs = require ( "fs" ) ;
66const path = require ( "path" ) ;
77const glob = require ( "glob" ) ;
88const indent = require ( "detect-indent" ) ;
99const logSymbols = require ( "log-symbols" ) ;
10- const chalk = require ( "chalk" ) ;
1110const cwd = process . cwd ( ) ;
1211
1312let oldVersion , newVersion ;
@@ -120,7 +119,7 @@ function runNpmScriptIfExists (manifest, script) {
120119 let pkgScripts = pkg . scripts ;
121120
122121 if ( pkgScripts && pkgScripts [ script ] ) {
123- exec ( "npm" , [ "run" , script ] , { stdio : "inherit" } ) ;
122+ ezSpawn . sync ( "npm" , [ "run" , script ] , { stdio : "inherit" } ) ;
124123 }
125124}
126125
@@ -199,12 +198,12 @@ function git (manifests, options) {
199198 commitMessage = "v" + newVersion + " " + options . commitMessage ;
200199 }
201200 commitArgs = commitArgs . concat ( [ "-m" , commitMessage ] ) ;
202- exec ( "git" , commitArgs ) ;
201+ ezSpawn . sync ( "git" , commitArgs ) ;
203202 console . log ( logSymbols . success , "Git commit" ) ;
204203
205204 // Git Tag
206205 if ( options . tag ) {
207- exec ( "git" , [ "tag" , "-a" , "v" + newVersion , "-m" , newVersion ] ) ;
206+ ezSpawn . sync ( "git" , [ "tag" , "-a" , "v" + newVersion , "-m" , newVersion ] ) ;
208207 console . log ( logSymbols . success , "Git tag" ) ;
209208 }
210209
@@ -214,34 +213,8 @@ function git (manifests, options) {
214213
215214 // Git Push
216215 if ( options . push ) {
217- exec ( "git" , [ "push" ] ) ;
218- options . tag && exec ( "git" , [ "push" , "--tags" ] ) ;
216+ ezSpawn . sync ( "git" , [ "push" ] ) ;
217+ options . tag && ezSpawn . sync ( "git" , [ "push" , "--tags" ] ) ;
219218 console . log ( logSymbols . success , "Git push" ) ;
220219 }
221220}
222-
223- /**
224- * Synchronously executes a command as a child process.
225- * An exception is thrown if the child process errors.
226- *
227- * @param {string } command - The command to run
228- * @param {string[] } args - An array of arguments to pass
229- */
230- function exec ( command , args , opts ) {
231- let result = spawnSync ( command , args , opts ) ;
232-
233- if ( result . status || result . error ) {
234- console . error (
235- chalk . bold . red ( "Error running command:" ) ,
236- chalk . reset . magenta ( command , args . join ( " " ) )
237- ) ;
238-
239- let err = result . error ;
240- if ( ! result . error ) {
241- let output = result . stdout . toString ( ) || result . stderr . toString ( ) ;
242- err = new Error ( output ) ;
243- }
244- err . status = result . status ;
245- throw err ;
246- }
247- }
0 commit comments