Skip to content

Commit e7a969d

Browse files
committed
Breaking: Rename opts.require to opts.preload
1 parent 638c18b commit e7a969d

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ const onPrepare = function (env) {
283283
MyApp.prepare({
284284
cwd: argv.cwd,
285285
configPath: argv.myappfile,
286-
require: argv.require,
286+
preload: argv.preload,
287287
completion: argv.completion
288288
}, onPrepare);
289289
```
@@ -376,7 +376,7 @@ myapp --myappfile /Users/name/Myappfile.js --cwd /var/www/project1
376376
myapp --myappfile /Users/name/Myappfile.js --cwd /var/www/project2
377377
```
378378

379-
#### opts.require
379+
#### opts.preload
380380

381381
A string or array of modules to attempt requiring from the local working directory before invoking the launch callback.
382382

@@ -387,21 +387,21 @@ Default: `null`
387387
```js
388388
var argv = require('minimist')(process.argv.slice(2));
389389
MyApp.launch({
390-
require: argv.require
390+
preload: argv.preload
391391
}, invoke);
392392
```
393393

394394
**Matching CLI Invocation:**
395395
```js
396-
myapp --require coffee-script/register
396+
myapp --preload coffee-script/register
397397
```
398398

399399
#### callback(env)
400400

401401
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:
402402

403403
- `cwd`: the current working directory
404-
- `require`: an array of modules that liftoff tried to pre-load
404+
- `preload`: an array of modules that liftoff tried to pre-load
405405
- `configNameSearch`: the config files searched for
406406
- `configPath`: the full path to your configuration file (if found)
407407
- `configBase`: the base directory of your configuration file (if found)
@@ -436,7 +436,7 @@ MyApp.prepare({}, onPrepare);
436436
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:
437437

438438
- `cwd`: the current working directory
439-
- `require`: an array of modules that liftoff tried to pre-load
439+
- `preload`: an array of modules that liftoff tried to pre-load
440440
- `configNameSearch`: the config files searched for
441441
- `configPath`: the full path to your configuration file (if found)
442442
- `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
448448

449449
#### `on('preload:before', function(name) {})`
450450

451-
Emitted before a module is pre-load. (But for only a module which is specified by `opts.require`.)
451+
Emitted before a module is pre-load. (But for only a module which is specified by `opts.preload`.)
452452

453453
```js
454-
var Hacker = new Liftoff({name:'hacker', require:'coffee-script'});
454+
var Hacker = new Liftoff({name:'hacker', preload:'coffee-script'});
455455
Hacker.on('preload:before', function (name) {
456456
console.log('Requiring external module: '+name+'...');
457457
});

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Liftoff.prototype.buildEnvironment = function(opts) {
3939
opts = opts || {};
4040

4141
// get modules we want to preload
42-
var preload = opts.require || [];
42+
var preload = opts.preload || [];
4343

4444
// ensure items to preload is an array
4545
if (!Array.isArray(preload)) {
@@ -131,7 +131,7 @@ Liftoff.prototype.buildEnvironment = function(opts) {
131131

132132
return {
133133
cwd: cwd,
134-
require: preload,
134+
preload: preload,
135135
configNameSearch: configNameSearch,
136136
configPath: configPath,
137137
configBase: configBase,
@@ -207,7 +207,7 @@ Liftoff.prototype.execute = function(env, forcedFlags, fn) {
207207

208208
function preloadModules(inst, env) {
209209
var basedir = env.cwd;
210-
env.require.filter(toUnique).forEach(function(module) {
210+
env.preload.filter(toUnique).forEach(function(module) {
211211
inst.requireLocal(module, basedir);
212212
});
213213
}

test/fixtures/respawn_and_require.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Test.on('preload:success', function(name) {
1414
});
1515

1616
Test.prepare({
17-
require: 'coffeescript/register',
17+
preload: 'coffeescript/register',
1818
}, function(env) {
1919
var forcedFlags = ['--lazy'];
2020
Test.execute(env, forcedFlags, function() {

test/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ describe('Liftoff', function() {
282282
app.on('preload:failure', function(moduleName, err) {
283283
done(err);
284284
});
285-
app.prepare({ require: ['coffeescript/register'] }, function(env) {
285+
app.prepare({ preload: ['coffeescript/register'] }, function(env) {
286286
app.execute(env, function(env) {
287-
expect(env.require).to.deep.equal(['coffeescript/register']);
287+
expect(env.preload).to.deep.equal(['coffeescript/register']);
288288
expect(logs).to.deep.equal(['preload:success']);
289289
done();
290290
});
@@ -302,9 +302,9 @@ describe('Liftoff', function() {
302302
app.on('preload:failure', function(moduleName, err) {
303303
done(err);
304304
});
305-
app.prepare({ require: 'coffeescript/register' }, function(env) {
305+
app.prepare({ preload: 'coffeescript/register' }, function(env) {
306306
app.execute(env, function(env) {
307-
expect(env.require).to.deep.equal(['coffeescript/register']);
307+
expect(env.preload).to.deep.equal(['coffeescript/register']);
308308
expect(logs).to.deep.equal(['preload:success']);
309309
done();
310310
});
@@ -319,9 +319,9 @@ describe('Liftoff', function() {
319319
expect(err).to.not.equal(null);
320320
logs.push('preload:failure');
321321
});
322-
app.prepare({ require: 'badmodule' }, function(env) {
322+
app.prepare({ preload: 'badmodule' }, function(env) {
323323
app.execute(env, function(env) {
324-
expect(env.require).to.deep.equal(['badmodule']);
324+
expect(env.preload).to.deep.equal(['badmodule']);
325325
expect(logs).to.deep.equal(['preload:failure']);
326326
done();
327327
});

0 commit comments

Comments
 (0)