Skip to content

Commit ce68d63

Browse files
Switched from cross-spawn to ez-spawn
1 parent 842a3b7 commit ce68d63

File tree

3 files changed

+41
-38
lines changed

3 files changed

+41
-38
lines changed

lib/index.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"use strict";
22

33
const SemVer = require("semver");
4-
const spawnSync = require("cross-spawn").sync;
4+
const ezSpawn = require("ez-spawn");
55
const fs = require("fs");
66
const path = require("path");
77
const glob = require("glob");
88
const indent = require("detect-indent");
99
const logSymbols = require("log-symbols");
10-
const chalk = require("chalk");
1110
const cwd = process.cwd();
1211

1312
let 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-
}

package-lock.json

Lines changed: 32 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"devDependencies": {
4646
"chai": "^4.2.0",
47+
"chai-exec": "^1.0.0",
4748
"coveralls": "^3.0.2",
4849
"del": "^3.0.0",
4950
"eslint": "^5.10.0",
@@ -56,8 +57,8 @@
5657
"dependencies": {
5758
"chalk": "^2.4.1",
5859
"commander": "^2.19.0",
59-
"cross-spawn": "^6.0.5",
6060
"detect-indent": "^5.0.0",
61+
"ez-spawn": "^2.1.0",
6162
"glob": "^7.1.3",
6263
"inquirer": "^6.2.1",
6364
"log-symbols": "^2.2.0",
@@ -69,4 +70,4 @@
6970
"engines": {
7071
"node": ">=6"
7172
}
72-
}
73+
}

0 commit comments

Comments
 (0)