UNPKG

@releaseotto/core

Version:

OTTO performs your action on new versioning of APIs, packages, schemas, etc. Keepings things nice and neatly automated.

38 lines 1.27 kB
import * as Shell from 'shelljs'; export function cloneRepository({ repository, branch, toLocation }) { let options = []; if (branch !== undefined) { options.push(`--branch ${branch}`); } if (!Shell.which('git')) { Shell.echo('Sorry, this script requires git'); Shell.exit(1); } const exec = Shell.exec(`git clone ${options.join(" ")} ${repository} ${toLocation}`); if (exec.code !== 0) { throw new Error(exec.stderr); } } export function commit({ location, commitMessage, push }) { if (!Shell.which('git')) { Shell.echo('Sorry, this script requires git'); Shell.exit(1); } Shell.cd(location); const somethingToCommit = Shell.exec('git diff-index --quiet HEAD --'); if (somethingToCommit.code === 0) { console.info('Nothing to commit, exits'); return; } const commit = Shell.exec(`git add --all && git commit -a -m"${commitMessage}"`); if (commit.code !== 0) { throw new Error(commit.stderr); } if (push) { const pushExec = Shell.exec(`git push --set-upstream ${push.origin} ${push.branch}`); if (pushExec.code !== 0) { throw new Error(pushExec.stderr); } } } //# sourceMappingURL=git.js.map