Skip to content

Commit 8575aba

Browse files
committed
Wrap entire shim in a iife
Close: #58 Fixes: istanbuljs/nyc#599 Ever so slightly different stylistic approach than @bcoe took in #58. Just wrap the whole thing so that we don't have to think about it.
1 parent 20db7c6 commit 8575aba

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

shim.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
// This module should *only* be loaded as a main script
24
// by child processes wrapped by spawn-wrap. It sets up
35
// argv to include the injected argv (including the user's
@@ -9,6 +11,9 @@
911
// a require('spawn-wrap').runMain() function that will strip
1012
// off the injected arguments and run the main file.
1113

14+
// wrap in iife for babylon to handle module-level return
15+
;(function () {
16+
1217
if (module !== require.main) {
1318
throw new Error('spawn-wrap: cli wrapper invoked as non-main script')
1419
}
@@ -170,3 +175,6 @@ spawnWrap(argv, env, __dirname)
170175
debug('shim runMain', process.argv)
171176
delete require.cache[process.argv[1]]
172177
Module.runMain()
178+
179+
// end iife wrapper for babylon
180+
})()

0 commit comments

Comments
 (0)