From 67781732bbb923fee9685a912f33a888a9737eca Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Tue, 12 Mar 2019 13:47:14 -0700 Subject: [PATCH] peer review changes also ensure `lib/cli/cli.js` is executable --- bin/mocha | 12 +++++++----- lib/cli/cli.js | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/mocha b/bin/mocha index 696c883023..df7cf48ca3 100755 --- a/bin/mocha +++ b/bin/mocha @@ -3,14 +3,14 @@ 'use strict'; /** - * This wrapper executable checks for known node flags and appends them when found, before invoking the "real" _mocha(1) executable. + * This wrapper executable checks for known node flags and appends them when found, + * before invoking the "real" executable (`lib/cli/cli.js`) * * @module bin/mocha * @private */ const {deprecate, warn} = require('../lib/utils'); -const {spawn} = require('child_process'); const {loadOptions} = require('../lib/cli/options'); const { unparseNodeFlags, @@ -22,7 +22,6 @@ const debug = require('debug')('mocha:cli:mocha'); const {aliases} = require('../lib/cli/run-option-metadata'); const nodeEnv = require('node-environment-flags'); -const mochaPath = require.resolve('./_mocha'); const mochaArgs = {}; const nodeArgs = {}; @@ -118,9 +117,12 @@ if (nodeArgs.gc) { delete nodeArgs.gc; } -debug('final node args', nodeArgs); - if (Object.keys(nodeArgs).length) { + const {spawn} = require('child_process'); + const mochaPath = require.resolve('../lib/cli/cli.js'); + + debug('final node args', nodeArgs); + const args = [].concat( unparseNodeFlags(nodeArgs), mochaPath, diff --git a/lib/cli/cli.js b/lib/cli/cli.js index 8e82983af4..dee8e70dd4 100755 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -1,3 +1,5 @@ +#!/usr/bin/env node + 'use strict'; /**