resolve absolute paths correctly on windows - fix #1

master
jden 10 years ago
parent 35a8e67493
commit 1699c829ec

@ -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;

@ -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'))
})
})
Loading…
Cancel
Save