diff --git a/index.js b/index.js index 8c8948c..a845af5 100644 --- a/index.js +++ b/index.js @@ -25,27 +25,25 @@ Toolkit.run(async tools => { version = 'minor' } - const exec = str => { - return process.stdout.write(execSync(str)) - } - try { const current = pkg.version.toString() - exec('git checkout master') - exec(`npm version --allow-same-version=true --git-tag-version=false ${current} `) + await tools.runInWorkspace('git', ['checkout', 'master']) + await tools.runInWorkspace('npm', + ['version', '--allow-same-version=true', '--git-tag-version=false', current, 'master']) console.log('current:', current, '/', 'version:', version) const newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString() console.log('new version:', newVersion) - exec(`git commit -a -m 'ci: ${commitMessage} ${newVersion}'`) + await tools.runInWorkspace('git', ['commit', '-a', '-m', `'ci: ${commitMessage} ${newVersion}'`]) const remoteRepo = `https://${process.env.GITHUB_ACTOR}:${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git` console.log('remoteRepo:', remoteRepo) - exec(`git tag ${newVersion}`) - exec(`git push "${remoteRepo}" --follow-tags`) - exec(`git push "${remoteRepo}" --tags`) + await tools.runInWorkspace('git', ['tag', '-a', newVersion]) + await tools.runInWorkspace('git', ['push', `"${remoteRepo}"`, '--follow-tags']) + await tools.runInWorkspace('git', ['push', `"${remoteRepo}"`, '--tags']) } catch (e) { - tools.exit.failure(`Failed: ${e.toString()}`) + tools.log.fatal(e) + tools.exit.failure('Failed to bump version') } tools.exit.success('Version bumped!') })