Skip to content

Commit 9d9e6c6

Browse files
plroebuckboneskull
authored andcommitted
feat(bin/options.js): Add support for comment lines in "mocha.opts"
Modified code to strip comment lines, those beginning with a hash character ('#'), from "mocha.opts" prior to processing its contents. Fixes #3370
1 parent e0306ff commit 9d9e6c6

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎bin/options.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function getOptions() {
3232
try {
3333
const opts = fs
3434
.readFileSync(optsPath, 'utf8')
35+
.replace(/^#.*$/gm, '')
3536
.replace(/\\\s/g, '%20')
3637
.split(/\s/)
3738
.filter(Boolean)

‎test/integration/regression.spec.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('regressions', function() {
3232
var processArgv = process.argv.join('');
3333
var mochaOpts = fs
3434
.readFileSync(path.join(__dirname, '..', 'mocha.opts'), 'utf-8')
35+
.replace(/^#.*$/gm, '')
3536
.split(/[\s]+/)
3637
.join('');
3738
assert.notEqual(

‎test/mocha.opts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
###
2+
### mocha.opts
3+
###
4+
15
--require ./test/setup
26
--ui bdd
37
--globals okGlobalA,okGlobalB
48
--globals okGlobalC
59
--globals callback*
610
--timeout 200
11+

0 commit comments

Comments
 (0)