Skip to content

Commit

Permalink
feat: always update user's name & email (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Apr 14, 2024
1 parent 3eccb67 commit 880a3c3
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions lib/deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 880a3c3

Please sign in to comment.