diff --git a/README.md b/README.md index ffdf7d2..50ec558 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,7 @@ const onPrepare = function (env) { MyApp.prepare({ cwd: argv.cwd, configPath: argv.myappfile, - require: argv.require, + preload: argv.preload, completion: argv.completion }, onPrepare); ``` @@ -376,7 +376,7 @@ myapp --myappfile /Users/name/Myappfile.js --cwd /var/www/project1 myapp --myappfile /Users/name/Myappfile.js --cwd /var/www/project2 ``` -#### opts.require +#### opts.preload A string or array of modules to attempt requiring from the local working directory before invoking the launch callback. @@ -387,13 +387,13 @@ Default: `null` ```js var argv = require('minimist')(process.argv.slice(2)); MyApp.launch({ - require: argv.require + preload: argv.preload }, invoke); ``` **Matching CLI Invocation:** ```js -myapp --require coffee-script/register +myapp --preload coffee-script/register ``` #### callback(env) @@ -401,7 +401,7 @@ myapp --require coffee-script/register A function called after your environment is prepared. A good place to modify the environment before calling `execute`. When invoked, `this` will be your instance of Liftoff. The `env` param will contain the following keys: - `cwd`: the current working directory -- `require`: an array of modules that liftoff tried to pre-load +- `preload`: an array of modules that liftoff tried to pre-load - `configNameSearch`: the config files searched for - `configPath`: the full path to your configuration file (if found) - `configBase`: the base directory of your configuration file (if found) @@ -436,7 +436,7 @@ MyApp.prepare({}, onPrepare); A function called after your application is executed. When invoked, `this` will be your instance of Liftoff, `argv` will be all command-line arguments (minus node & v8 flags), and `env` will contain the following keys: - `cwd`: the current working directory -- `require`: an array of modules that liftoff tried to pre-load +- `preload`: an array of modules that liftoff tried to pre-load - `configNameSearch`: the config files searched for - `configPath`: the full path to your configuration file (if found) - `configBase`: the base directory of your configuration file (if found) @@ -448,10 +448,10 @@ A function called after your application is executed. When invoked, `this` will #### `on('preload:before', function(name) {})` -Emitted before a module is pre-load. (But for only a module which is specified by `opts.require`.) +Emitted before a module is pre-load. (But for only a module which is specified by `opts.preload`.) ```js -var Hacker = new Liftoff({name:'hacker', require:'coffee-script'}); +var Hacker = new Liftoff({name:'hacker', preload:'coffee-script'}); Hacker.on('preload:before', function (name) { console.log('Requiring external module: '+name+'...'); }); diff --git a/index.js b/index.js index 559634f..216952e 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ Liftoff.prototype.buildEnvironment = function(opts) { opts = opts || {}; // get modules we want to preload - var preload = opts.require || []; + var preload = opts.preload || []; // ensure items to preload is an array if (!Array.isArray(preload)) { @@ -131,7 +131,7 @@ Liftoff.prototype.buildEnvironment = function(opts) { return { cwd: cwd, - require: preload, + preload: preload, configNameSearch: configNameSearch, configPath: configPath, configBase: configBase, @@ -207,7 +207,7 @@ Liftoff.prototype.execute = function(env, forcedFlags, fn) { function preloadModules(inst, env) { var basedir = env.cwd; - env.require.filter(toUnique).forEach(function(module) { + env.preload.filter(toUnique).forEach(function(module) { inst.requireLocal(module, basedir); }); } diff --git a/test/fixtures/respawn_and_require.js b/test/fixtures/respawn_and_require.js index bc9ef19..fcc2030 100644 --- a/test/fixtures/respawn_and_require.js +++ b/test/fixtures/respawn_and_require.js @@ -14,7 +14,7 @@ Test.on('preload:success', function(name) { }); Test.prepare({ - require: 'coffeescript/register', + preload: 'coffeescript/register', }, function(env) { var forcedFlags = ['--lazy']; Test.execute(env, forcedFlags, function() { diff --git a/test/index.js b/test/index.js index 38f4e66..7c25499 100644 --- a/test/index.js +++ b/test/index.js @@ -282,9 +282,9 @@ describe('Liftoff', function() { app.on('preload:failure', function(moduleName, err) { done(err); }); - app.prepare({ require: ['coffeescript/register'] }, function(env) { + app.prepare({ preload: ['coffeescript/register'] }, function(env) { app.execute(env, function(env) { - expect(env.require).to.deep.equal(['coffeescript/register']); + expect(env.preload).to.deep.equal(['coffeescript/register']); expect(logs).to.deep.equal(['preload:success']); done(); }); @@ -302,9 +302,9 @@ describe('Liftoff', function() { app.on('preload:failure', function(moduleName, err) { done(err); }); - app.prepare({ require: 'coffeescript/register' }, function(env) { + app.prepare({ preload: 'coffeescript/register' }, function(env) { app.execute(env, function(env) { - expect(env.require).to.deep.equal(['coffeescript/register']); + expect(env.preload).to.deep.equal(['coffeescript/register']); expect(logs).to.deep.equal(['preload:success']); done(); }); @@ -319,9 +319,9 @@ describe('Liftoff', function() { expect(err).to.not.equal(null); logs.push('preload:failure'); }); - app.prepare({ require: 'badmodule' }, function(env) { + app.prepare({ preload: 'badmodule' }, function(env) { app.execute(env, function(env) { - expect(env.require).to.deep.equal(['badmodule']); + expect(env.preload).to.deep.equal(['badmodule']); expect(logs).to.deep.equal(['preload:failure']); done(); });