diff --git a/index.js b/index.js index 9343ed0..c60250f 100644 --- a/index.js +++ b/index.js @@ -61,5 +61,6 @@ function read(fp, cb) { function resolve(options) { options = options || {}; var cwd = options.cwd ? path.resolve(options.cwd) : process.cwd(); - return path.join(cwd, options.path || '.git/config'); + return path.resolve(cwd, options.path || '.git/config'); } +module.exports.resolve = resolve; \ No newline at end of file diff --git a/test.js b/test.js index 11df91a..29d7b0f 100644 --- a/test.js +++ b/test.js @@ -43,3 +43,22 @@ describe('async:', function () { }); }); }); + +describe('resolve:', function () { + it('should resolve the git config in the cwd by default', function () { + var sep = require('path').sep; + git.resolve().should.equal(process.cwd() + sep + '.git' + sep + 'config'); + }) + it('should allow override path', function () { + var path = require('path').resolve(process.env.HOME, '.gitconfig') + git.resolve({path: path}).should.equal(path); + }) + it('should resolve relative path to cwd', function () { + git.resolve({path: '.config'}) + .should.equal(require('path').resolve(process.cwd(), '.config')); + }) + it('should allow override of cwd', function () { + git.resolve({path: '.config', cwd: '/opt/config'}) + .should.equal(require('path').resolve('/opt/config','.config')) + }) +}) \ No newline at end of file