Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #127

Closed
wants to merge 2 commits into from
Closed

WIP #127

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions index.js
Expand Up @@ -6,7 +6,6 @@ var extend = require('extend');
var resolve = require('resolve');
var flaggedRespawn = require('flagged-respawn');
var isPlainObject = require('is-plain-object').isPlainObject;
var mapValues = require('object.map');
var fined = require('fined');

var findCwd = require('./lib/find_cwd');
Expand Down Expand Up @@ -124,10 +123,10 @@ Liftoff.prototype.buildEnvironment = function (opts) {
return config;
}

var configFiles = {};
if (isPlainObject(this.configFiles)) {
configFiles = mapValues(this.configFiles, function (searchPaths, fileStem) {
var defaultObj = { name: fileStem, cwd: cwd, extensions: exts };
var configFiles = [];
if (Array.isArray(this.configFiles)) {
configFiles = this.configFiles.map(function (searchPaths) {
var defaultObj = { cwd: cwd, extensions: exts };

var foundPath = arrayFind(searchPaths, function (pathObj) {
return findAndRegisterLoader(pathObj, defaultObj);
Expand All @@ -137,7 +136,7 @@ Liftoff.prototype.buildEnvironment = function (opts) {
});
}

var config = mapValues(configFiles, function (startingLocation) {
var config = configFiles.map(function (startingLocation) {
var defaultConfig = {};
if (!startingLocation) {
return defaultConfig;
Expand All @@ -164,7 +163,12 @@ Liftoff.prototype.buildEnvironment = function (opts) {
var configPath = findConfig({
configNameSearch: configNameSearch,
searchPaths: searchPaths,
configPath: opts.configPath,
// If the configPath was not specified, look for the configName inside each `config` object to see if it was overridden
configPath: opts.configPath || arrayFind(config, function (cfg) {
if (Object.prototype.hasOwnProperty.call(cfg, this.configName)) {
return cfg[this.configName];
}
}),
});

// if we have a config path, save the directory it resides in.
Expand Down