Skip to content

Commit

Permalink
chore: Rename to forcedFlags & specify it in launch opts instead of c…
Browse files Browse the repository at this point in the history
…onstructor
  • Loading branch information
phated committed Nov 22, 2021
1 parent 0f4dd50 commit d741319
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ Liftoff.prototype.launch = function (opts, fn) {

var env = this.buildEnvironment(opts);

var nodeFlags = getNodeFlags.arrayOrFunction(this.nodeFlags, env);
flaggedRespawn(flags, process.argv, nodeFlags, execute.bind(this));
var forcedFlags = getNodeFlags.arrayOrFunction(opts.forcedFlags, env);
flaggedRespawn(flags, process.argv, forcedFlags, execute.bind(this));

function execute(ready, child, argv) {
if (child !== process) {
Expand Down
9 changes: 5 additions & 4 deletions test/fixtures/nodeflags_only.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ const Liftoff = require('../..');

const Test = new Liftoff({
name: 'test',
nodeFlags: function(opts, env) {
return ['--lazy'];
},
});

Test.on('respawn', function(execArgv) {
console.log('saw respawn', execArgv);
});

Test.launch({}, function(env, argv) {
Test.launch({
forcedFlags: function(env) {
return ['--lazy'];
},
}, function(env, argv) {
console.error(argv.slice(1).join(' '));
});
5 changes: 3 additions & 2 deletions test/fixtures/v8flags_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ const Liftoff = require('../..');
const Test = new Liftoff({
name: 'test',
v8flags: ['--harmony'],
nodeFlags: ['--lazy'],
});

Test.on('respawn', function(flags, proc) {
console.log('saw respawn', flags);
});

Test.launch({}, function(env, argv) {
Test.launch({
forcedFlags: ['--lazy'],
}, function(env, argv) {
console.error(argv.slice(1).join(' '));
});
8 changes: 4 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('Liftoff', function () {
});
});

it('should respawn if v8flag is set by opts.nodeFlags', function(done) {
it('should respawn if v8flag is set by opts.forcedFlags', function(done) {
exec('node test/fixtures/v8flags_config.js 123', cb);

function cb(err, stdout, stderr) {
Expand All @@ -259,7 +259,7 @@ describe('Liftoff', function () {
}
});

it('should respawn if v8flag is set by both cli flag and opts.nodeFlags', function(done) {
it('should respawn if v8flag is set by both cli flag and opts.forcedFlags', function(done) {
exec('node test/fixtures/v8flags_config.js 123 --harmony abc', cb);

function cb(err, stdout, stderr) {
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('Liftoff', function () {
});
});

it('should respawn if v8flags is empty but nodeFlags are specified',
it('should respawn if v8flags is empty but forcedFlags are specified',
function(done) {
exec('node test/fixtures/nodeflags_only.js 123', cb);

Expand Down Expand Up @@ -505,7 +505,7 @@ describe('Liftoff', function () {
logFailure.push({ moduleName: moduleName, error: error });
});
app.on('require', function(moduleName, module) {
logRequire.push({ moduleName: moduleName, module: module });
logRequire.push({ moduleName: moduleName, module: module });
});
app.launch({}, function(env) {
expect(env.configFiles).to.deep.equal({
Expand Down

0 comments on commit d741319

Please sign in to comment.