diff options
Diffstat (limited to 'node_modules/liftoff/index.js')
-rw-r--r-- | node_modules/liftoff/index.js | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/node_modules/liftoff/index.js b/node_modules/liftoff/index.js index 0c0a8d5e9..7415dcfe3 100644 --- a/node_modules/liftoff/index.js +++ b/node_modules/liftoff/index.js @@ -6,8 +6,8 @@ const EE = require('events').EventEmitter; const extend = require('extend'); const resolve = require('resolve'); const flaggedRespawn = require('flagged-respawn'); -const isPlainObject = require('lodash.isplainobject'); -const mapValues = require('lodash.mapvalues'); +const isPlainObject = require('is-plain-object'); +const mapValues = require('object.map'); const fined = require('fined'); const findCwd = require('./lib/find_cwd'); @@ -17,6 +17,7 @@ const parseOptions = require('./lib/parse_options'); const silentRequire = require('./lib/silent_require'); const buildConfigName = require('./lib/build_config_name'); const registerLoader = require('./lib/register_loader'); +const getNodeFlags = require('./lib/get_node_flags'); function Liftoff (opts) { @@ -91,7 +92,7 @@ Liftoff.prototype.buildEnvironment = function (opts) { // locate local module and package next to config or explicitly provided cwd var modulePath, modulePackage; try { - var delim = (process.platform === 'win32' ? ';' : ':'), + var delim = path.delimiter, paths = (process.env.NODE_PATH ? process.env.NODE_PATH.split(delim) : []); modulePath = resolve.sync(this.moduleName, {basedir: configBase || cwd, paths: paths}); modulePackage = silentRequire(fileSearch('package.json', [modulePath])); @@ -185,21 +186,21 @@ Liftoff.prototype.launch = function (opts, fn) { this.handleFlags(function (err, flags) { if (err) { throw err; - } else { - if (flags) { - flaggedRespawn(flags, process.argv, function (ready, child) { - if (child !== process) { - this.emit('respawn', process.argv.filter(function (arg) { - var flag = arg.split('=')[0]; - return flags.indexOf(flag) !== -1; - }.bind(this)), child); - } - if (ready) { - fn.call(this, this.buildEnvironment(opts)); - } - }.bind(this)); - } else { - fn.call(this, this.buildEnvironment(opts)); + } + flags = flags || []; + + var env = this.buildEnvironment(opts); + + var forcedFlags = getNodeFlags.arrayOrFunction(opts.forcedFlags, env); + flaggedRespawn(flags, process.argv, forcedFlags, execute.bind(this)); + + function execute(ready, child, argv) { + if (child !== process) { + var execArgv = getNodeFlags.fromReorderedArgv(argv); + this.emit('respawn', execArgv, child); + } + if (ready) { + fn.call(this, env, argv); } } }.bind(this)); |