From 91c4ca5e0dce67d3d4e71506117f5346acb7695b Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 15 Jun 2019 14:27:01 -0700 Subject: [PATCH] Publish addons with right cwd and don't exit Part of #2165 --- bin/publish.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bin/publish.js b/bin/publish.js index fb6b3ee2ba..e03fa6abb1 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -50,9 +50,8 @@ function checkAndPublishPackage(packageDir) { // Set the version in package.json const packageJsonFile = path.join(packageDir, 'package.json'); packageJson.version = nextVersion; - if (isDryRun) { - console.log(`Set version of ${packageJsonFile} to ${nextVersion}`); - } else { + console.log(`Set version of ${packageJsonFile} to ${nextVersion}`); + if (!isDryRun) { fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2)); } @@ -61,11 +60,16 @@ function checkAndPublishPackage(packageDir) { if (!isStableRelease) { args.push('--tag', 'beta'); } - if (isDryRun) { - console.log(`Spawn: npm ${args.join(' ')}`); - } else { - const result = cp.spawn('npm', args, { stdio: 'inherit' }); - result.on('exit', code => process.exit(code)); + console.log(`Spawn: npm ${args.join(' ')}`); + if (!isDryRun) { + const result = cp.spawnSync('npm', args, { + cwd: packageDir, + stdio: 'inherit' + }); + if (result.status) { + console.error(`Spawn exited with code ${result.status}`); + process.exit(result.status); + } } console.groupEnd();