Skip to content

Commit

Permalink
Merge pull request #92 from pelias/path.resolve
Browse files Browse the repository at this point in the history
fix(PELIAS_CONFIG): properly suport relative paths
  • Loading branch information
orangejulius authored Jun 5, 2018
2 parents 652de2d + 353fbbd commit 8cb5150
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function getConfig(deep) {
// load config from ENV
let custom_config;
if( process.env.hasOwnProperty('PELIAS_CONFIG') ){
custom_config = require( process.env.PELIAS_CONFIG );
custom_config = require( path.resolve(process.env.PELIAS_CONFIG) );
} else if ( fs.existsSync (localpath) ) {
custom_config = require( localpath );
}
Expand Down
13 changes: 13 additions & 0 deletions test/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ module.exports.generate.paths = function(test) {
delete process.env.PELIAS_CONFIG;
});

test('relative paths supported from any location', function (t) {
process.chdir('./config');
// set the relative PELIAS_CONFIG env var
process.env.PELIAS_CONFIG = './env.json';

var c = config.generate();
t.deepEqual(c, expected, 'loaded relative file path');
t.end();

// unset the PELIAS_CONFIG env var
delete process.env.PELIAS_CONFIG;
});

test('invalid paths in ENV var throws exception', function (t) {

// set the relative PELIAS_CONFIG env var
Expand Down

0 comments on commit 8cb5150

Please sign in to comment.