Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(options) {
try {
const gc = gitconfig(Object.assign({type: 'global'}, options && options.gitconfig));
options = Object.assign({cwd: '/', path: gc}, options);
const config = parse.sync(options) || {};
return config.user ? config.user : null;
} catch (err) {
// Dont log on CI/CD
if (!process.env.NODE_ENV) {
console.log('WARNING Could not determine git user info', err)
}
}
};
if (gitDir) {
this._gitFolder = rootPath;
gri._changeGitDir(gitDir);
} else {
this._gitFolder = Utils.FindGitFolder(rootPath);
}
if (this._gitFolder !== undefined) {
// With parse-git-config, cwd is the directory containing the path, .git/config, you want to sync
this._gitParentFolder = path.dirname(this._gitFolder);
let syncObj: any = { cwd: this._gitParentFolder };
//If gitDir, send pgc the exact path to the config file to use
if (gitDir) {
syncObj = { path: path.join(this._gitFolder, "config") };
}
this._gitConfig = pgc.sync(syncObj);
/* tslint:disable:quotemark */
const remote: any = this._gitConfig['remote "origin"'];
/* tslint:enable:quotemark */
if (remote === undefined) {
return;
}
this._gitOriginalRemoteUrl = remote.url;
if (gitDir) {
this._gitRepoInfo = gri(this._gitParentFolder);
} else {
this._gitRepoInfo = gri(this._gitFolder);
}
this._gitCurrentBranch = this._gitRepoInfo.branch;
function gitConfigUrl(configPath) {
const options = configPath ? { path: configPath } : {};
const config = parseGitConfig.sync(options);
const originProp = Object.keys(config).find(key => /^remote/.test(key));
return originProp ? config[originProp].url : '';
}
originUrl.sync = options => {
if (typeof options === 'string') {
options = { path: options };
}
let parsed = parse.sync(options);
if (parsed) {
let origin = parsed[getKey(parsed)];
return origin ? origin.url : void 0;
}
};
const defaults = {
name: '',
description: '',
author: config.get('author'),
repo: (info) => `${info.author}/${info.name}`,
license: config.get('license', 'MIT'),
manager: config.get('manager', 'npm'),
template: config.get('template', 'light')
}
try {
if (!config.get('author')) {
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 (defaults.author) {
config.set('author', defaults.author)
}
}
if (!config.get('manager')) {
if (which.sync('yarn', { nothrow: true })) {
defaults.manager = 'yarn'
module.exports = function gitUserEmail(opts) {
opts = extend({cwd: '/', path: gitconfig()}, opts);
var config = parse.sync(opts);
if (typeof config === 'object' && config.hasOwnProperty('user')) {
return config.user.email;
}
return null;
};
function getHomepage (project, context) {
const gitConfigPath = path.join(project.path, '.git', 'config')
if (fs.existsSync(gitConfigPath)) {
const gitConfig = parseGitConfig.sync({ path: gitConfigPath })
const gitRemoteUrl = gitConfig['remote "origin"']
if (gitRemoteUrl) {
return getHttpsGitURL(gitRemoteUrl.url)
}
}
const pkg = folders.readPackage(project.path, context)
return pkg.homepage
}
module.exports = async () => {
const defaults = {
name: '',
description: 'Powered by Saasify',
author: config.get('author'),
repo: (info) => `${info.author}/${info.name}`,
license: config.get('license', 'MIT'),
template: config.get('template', 'typescript')
}
try {
if (!config.get('author')) {
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 (defaults.author) {
config.set('author', defaults.author)
}
}
} catch (err) {}
return defaults
}