Skip to content

Commit

Permalink
feat: get default author from git config
Browse files Browse the repository at this point in the history
  • Loading branch information
int64ago committed Sep 22, 2019
1 parent a77fcb8 commit 76df59c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
isSvrxPlugin,
correctName,
correctFullName,
getAuthor,
} = require('./utils');

module.exports = (name) => {
Expand Down Expand Up @@ -76,7 +77,7 @@ module.exports = (name) => {
type: 'input',
name: 'author',
message: 'The author:',
default: 'svrx',
default: getAuthor(),
},
{
type: 'list',
Expand Down
10 changes: 10 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ exports.spawn = (cmd, args, opts = {}) => {
});
});
};

exports.getAuthor = () => {
try {
const name = cp.execSync('git config --get user.name');
const email = cp.execSync('git config --get user.email');
return `${name.toString().trim()} <${email.toString().trim()}>`;
} catch (err) {
return 'svrx';
}
};

0 comments on commit 76df59c

Please sign in to comment.