diff --git a/lib/deployer.js b/lib/deployer.js index c817e53..97740ce 100644 --- a/lib/deployer.js +++ b/lib/deployer.js @@ -55,32 +55,30 @@ module.exports = function(args) { }); } - function setup() { + async function setNameEmail() { const userName = args.name || args.user || args.userName || ''; const userEmail = args.email || args.userEmail || ''; + userName && await git('config', 'user.name', userName); + userEmail && await git('config', 'user.email', userEmail); + } + + async function setup() { // Create a placeholder for the first commit - return fs.writeFile(pathFn.join(deployDir, 'placeholder'), '').then(() => { - return git('init'); - }).then(() => { - return userName && git('config', 'user.name', userName); - }).then(() => { - return userEmail && git('config', 'user.email', userEmail); - }).then(() => { - return git('add', '-A'); - }).then(() => { - return git('commit', '-m', 'First commit'); - }); + await fs.writeFile(pathFn.join(deployDir, 'placeholder'), ''); + await git('init'); + await setNameEmail(); + await git('add', '-A'); + await git('commit', '-m', 'First commit'); } - function push(repo) { - return git('add', '-A').then(() => { - return git('commit', '-m', message).catch(() => { - // Do nothing. It's OK if nothing to commit. - }); - }).then(() => { - return git('push', '-u', repo.url, 'HEAD:' + repo.branch, '--force'); + async function push(repo) { + await setNameEmail(); + await git('add', '-A'); + await git('commit', '-m', message).catch(() => { + // Do nothing. It's OK if nothing to commit. }); + await git('push', '-u', repo.url, 'HEAD:' + repo.branch, '--force'); } return fs.exists(deployDir).then(exist => {