From 8596db3bac98972d26e1ea569cab538d84dbbb49 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 4 Aug 2015 01:30:53 +0100 Subject: [PATCH] fix git exec commands in babel-plugin --- packages/babel-cli/src/babel-plugin/index.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/babel-cli/src/babel-plugin/index.js b/packages/babel-cli/src/babel-plugin/index.js index 7b85447f99..522d2e7f40 100755 --- a/packages/babel-cli/src/babel-plugin/index.js +++ b/packages/babel-cli/src/babel-plugin/index.js @@ -45,6 +45,14 @@ function write(filename, content) { fs.writeFileSync(filename, content); } +function execMaybe(cmd) { + try { + return child.execSync(cmd).toString(); + } catch (err) { + return ""; + } +} + var rl = readline.createInterface({ input: process.stdin, output: process.stdout @@ -61,7 +69,7 @@ var cmds = { } rl.question("Description (optional): ", function (description) { - var remote = child.execSync("git config --get remote.origin.url").trim().match(/git@github.com:(.*?).git/); + var remote = execMaybe("git config --get remote.origin.url").trim().match(/git@github.com:(.*?).git/); if (remote) { build(description, remote[1]); } else { @@ -93,9 +101,9 @@ var cmds = { }, scripts: { - publish: "babel-plugin publish", - build: "babel-plugin build", - test: "babel-plugin test" + build: "babel-plugin build", + push: "babel-plugin publish", + test: "babel-plugin test" }, keywords: ["babel-plugin"] @@ -108,8 +116,8 @@ var cmds = { write("README.md", template("README.md", templateData)); write("LICENSE", template("LICENSE", { - AUTHOR_EMAIL: child.execSync("git config --get user.email").trim(), - AUTHOR_NAME: child.execSync("git config --get user.name").trim(), + AUTHOR_EMAIL: execMaybe("git config --get user.email").trim(), + AUTHOR_NAME: execMaybe("git config --get user.name").trim(), YEAR: new Date().getFullYear() }));