Skip to content

Commit

Permalink
closes #3727
Browse files Browse the repository at this point in the history
Fixes support for multiple node flags
  • Loading branch information
Adam Ginzberg authored and adam-codaio committed Mar 1, 2019
1 parent 22831c5 commit 99ceb16
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/cli/node-flags.js
Expand Up @@ -81,5 +81,6 @@ exports.unparseNodeFlags = opts => {
.split(/\b/)
.map(arg => (arg === ' ' ? '=' : arg))
.join('')
.split(' ')
: [];
};
48 changes: 47 additions & 1 deletion test/node-unit/cli/node-flags.spec.js
@@ -1,7 +1,11 @@
'use strict';

const nodeEnvFlags = require('node-environment-flags');
const {isNodeFlag, impliesNoTimeouts} = require('../../../lib/cli/node-flags');
const {
isNodeFlag,
impliesNoTimeouts,
unparseNodeFlags
} = require('../../../lib/cli/node-flags');

describe('node-flags', function() {
describe('isNodeFlag()', function() {
Expand Down Expand Up @@ -86,4 +90,46 @@ describe('node-flags', function() {
expect(impliesNoTimeouts('inspect-brk'), 'to be true');
});
});

describe('unparseNodeFlags()', function() {
it('should handle single v8 flags', function() {
expect(unparseNodeFlags({'v8-numeric': 100}), 'to equal', [
'--v8-numeric=100'
]);
expect(unparseNodeFlags({'v8-boolean': true}), 'to equal', [
'--v8-boolean'
]);
});

it('should handle multiple v8 flags', function() {
expect(
unparseNodeFlags({'v8-numeric-one': 1, 'v8-numeric-two': 2}),
'to equal',
['--v8-numeric-one=1', '--v8-numeric-two=2']
);
expect(
unparseNodeFlags({'v8-boolean-one': true, 'v8-boolean-two': true}),
'to equal',
['--v8-boolean-one', '--v8-boolean-two']
);
expect(
unparseNodeFlags({
'v8-boolean-one': true,
'v8-numeric-one': 1,
'v8-boolean-two': true
}),
'to equal',
['--v8-boolean-one', '--v8-numeric-one=1', '--v8-boolean-two']
);
expect(
unparseNodeFlags({
'v8-numeric-one': 1,
'v8-boolean-one': true,
'v8-numeric-two': 2
}),
'to equal',
['--v8-numeric-one=1', '--v8-boolean-one', '--v8-numeric-two=2']
);
});
});
});

0 comments on commit 99ceb16

Please sign in to comment.