fix(config): cleanup absolute path config function (#8641)

refs https://github.com/TryGhost/Ghost-CLI/issues/228

- don't try to reinvent path.isAbsolute
This commit is contained in:
Austin Burdine 2017-07-05 18:04:18 -04:00 committed by Katharina Irrgang
parent dc25c06b31
commit 49c8277390
2 changed files with 7 additions and 8 deletions

View File

@ -34,13 +34,12 @@ exports.makePathsAbsolute = function makePathsAbsolute(obj, parent) {
_.each(obj, function (configValue, pathsKey) {
if (_.isObject(configValue)) {
makePathsAbsolute.bind(self)(configValue, parent + ':' + pathsKey);
} else {
if (_.isString(configValue) &&
(configValue.match(/\/+|\\+/) || configValue === '.') &&
(configValue[0] !== '/' && configValue[0] !== '\\')
) {
self.set(parent + ':' + pathsKey, path.join(__dirname + '/../../../', configValue));
}
} else if (
_.isString(configValue) &&
(configValue.match(/\/+|\\+/) || configValue === '.') &&
!path.isAbsolute(configValue)
) {
self.set(parent + ':' + pathsKey, path.normalize(path.join(__dirname, '../../..', configValue)));
}
});
};

View File

@ -41,7 +41,7 @@ describe('UNIT: Config utils', function () {
changedKey.length.should.eql(0);
});
it('ensure we don\' change absolute paths', function () {
it('ensure we don\'t change absolute paths', function () {
var changedKey = [],
obj = {
database: {