2018-03-04 15:43:18 -05:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const getGitConfigPath = require('git-config-path')
|
|
|
|
const githubUsername = require('github-username')
|
|
|
|
const parseGitConfig = require('parse-git-config')
|
|
|
|
const which = require('which')
|
|
|
|
|
|
|
|
module.exports = async () => {
|
|
|
|
const defaults = {
|
|
|
|
author: undefined,
|
|
|
|
manager: 'npm'
|
|
|
|
}
|
|
|
|
|
2018-03-07 03:05:39 -05:00
|
|
|
// TODO: TEMP
|
|
|
|
defaults.author = 'transitive-bullshit'
|
|
|
|
defaults.manager = 'yarn'
|
|
|
|
return defaults
|
|
|
|
|
2018-03-04 15:43:18 -05:00
|
|
|
try {
|
|
|
|
const gitConfigPath = getGitConfigPath('global')
|
|
|
|
|
|
|
|
if (gitConfigPath) {
|
|
|
|
const gitConfig = parseGitConfig.sync({ path: gitConfigPath })
|
|
|
|
|
|
|
|
if (gitConfig.github && gitConfig.github.user) {
|
|
|
|
defaults.author = gitConfig.github.user
|
|
|
|
} else if (gitConfig.user && gitConfig.user.email) {
|
|
|
|
defaults.author = await githubUsername(gitConfig.user.email)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (which.sync('yarn', { nothrow: true })) {
|
|
|
|
defaults.manager = 'yarn'
|
|
|
|
}
|
|
|
|
} catch (err) { }
|
|
|
|
|
|
|
|
return defaults
|
|
|
|
}
|