qspark-deploy
Version:
齐圣园区自动化部署
25 lines (20 loc) • 676 B
JavaScript
;
const fs = require('fs');
const os = require('os');
const path = require('path');
module.exports = function (type) {
let configPath = '';
const workDir = process.cwd();
if (type === 'global') {
configPath = path.join(os.homedir(), '.gitconfig');
} else {
configPath = path.resolve(workDir, '.git/config');
if (!fs.existsSync(configPath)) {
configPath = path.resolve(workDir, '../.git/config');
}
}
if (!fs.existsSync(configPath)) {
configPath = path.join(os.homedir(), '.config/git/config');
}
return fs.existsSync(configPath) ? configPath : null;
}