Skip to content

Commit

Permalink
chore!: Remove launch API
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Nov 22, 2021
1 parent 3814a48 commit dea6860
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 611 deletions.
31 changes: 0 additions & 31 deletions README.md
Expand Up @@ -444,37 +444,6 @@ A function called after your application is executed. When invoked, `this` will
- `modulePackage`: the contents of the local module's package.json (if found)
- `configFiles`: an object of filepaths for each found config file (filepath values will be null if not found)

### launch(opts, callback(env, argv))

**Deprecated:** Please use `prepare` followed by `execute`. That's all this module does internally but those give you more control.

Launches your application with provided options, builds an environment, and invokes your callback, passing the calculated environment and command-line arguments (minus node & v8 flags) as the arguments.

Accepts any options that `prepare` allows, plus `opt.forcedFlags`.

#### opts.forcedFlags

**Deprecated:** If using `prepare`/`execute`, pass forcedFlags as the 2nd argument instead of using this option.

Allows you to force node or V8 flags during the launch. This is useful if you need to make sure certain flags will always be enabled or if you need to enable flags that don't show up in `opts.v8flags` (as these flags aren't validated against `opts.v8flags`).

If this is specified as a function, it will receive the built `env` as its only argument and must return a string or array of flags to force.

Type: `String|Array|Function`
Default: `null`

**Example Configuration:**
```js
MyApp.launch({
forcedFlags: ['--trace-deprecation']
}, invoke);
```

**Matching CLI Invocation:**
```js
myapp --trace-deprecation
```

### events

#### require(name, module)
Expand Down
13 changes: 0 additions & 13 deletions index.js
Expand Up @@ -204,19 +204,6 @@ Liftoff.prototype.execute = function(env, forcedFlags, fn) {
}.bind(this));
};

Liftoff.prototype.launch = function(opts, fn) {
if (typeof fn !== 'function') {
throw new Error('You must provide a callback function.');
}

var self = this;

self.prepare(opts, function(env) {
var forcedFlags = getNodeFlags.arrayOrFunction(opts.forcedFlags, env);
self.execute(env, forcedFlags, fn);
});
};

function preloadModules(inst, env) {
var basedir = env.cwd;
env.require.filter(toUnique).forEach(function(module) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -17,8 +17,7 @@
],
"scripts": {
"pretest": "eslint .",
"test": "mocha -t 5000 -b -R spec test/index && npm run legacy-test",
"legacy-test": "mocha -t 5000 -b -R spec test/launch",
"test": "mocha -t 5000 -b -R spec test/index",
"cover": "nyc --reporter=lcov --reporter=text-summary npm test"
},
"dependencies": {
Expand Down
10 changes: 6 additions & 4 deletions test/fixtures/developing_yourself/app1/index.js
Expand Up @@ -4,8 +4,10 @@ var app1 = new Liftoff({
name: 'app1'
});

app1.launch({}, function(env) {
console.log(env.modulePackage);
console.log(env.modulePath);
console.log(env.cwd);
app1.prepare({}, function(env) {
app1.execute(env, function(env) {
console.log(env.modulePackage);
console.log(env.modulePath);
console.log(env.cwd);
});
});
10 changes: 6 additions & 4 deletions test/fixtures/developing_yourself/app2/index.js
Expand Up @@ -4,8 +4,10 @@ var app2 = new Liftoff({
name: 'app2'
});

app2.launch({}, function(env) {
console.log(JSON.stringify(env.modulePackage));
console.log(env.modulePath);
console.log(env.cwd);
app2.prepare({}, function(env) {
app2.execute(env, function(env) {
console.log(JSON.stringify(env.modulePackage));
console.log(env.modulePath);
console.log(env.cwd);
});
});
10 changes: 6 additions & 4 deletions test/fixtures/developing_yourself/main.js
Expand Up @@ -4,8 +4,10 @@ var app0 = new Liftoff({
name: 'app0'
});

app0.launch({}, function(env) {
console.log(JSON.stringify(env.modulePackage));
console.log(env.modulePath);
console.log(env.cwd);
app0.prepare({}, function(env) {
app0.execute(env, function(env) {
console.log(JSON.stringify(env.modulePackage));
console.log(env.modulePath);
console.log(env.cwd);
});
});
17 changes: 0 additions & 17 deletions test/fixtures/nodeflags_only.js

This file was deleted.

10 changes: 6 additions & 4 deletions test/fixtures/respawn_and_require.js
Expand Up @@ -13,9 +13,11 @@ Test.on('require', function(name) {
console.log('require', name);
});

Test.launch({
Test.prepare({
require: 'coffeescript/register',
forcedFlags: ['--lazy'],
}, function(env, argv) {
console.log('execute');
}, function(env) {
var forcedFlags = ['--lazy'];
Test.execute(env, forcedFlags, function() {
console.log('execute');
});
});
13 changes: 0 additions & 13 deletions test/fixtures/v8flags.js

This file was deleted.

16 changes: 0 additions & 16 deletions test/fixtures/v8flags_config.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/fixtures/v8flags_error.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/fixtures/v8flags_function.js

This file was deleted.

13 changes: 0 additions & 13 deletions test/fixtures/v8flags_value.js

This file was deleted.

0 comments on commit dea6860

Please sign in to comment.