Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix main module shimming for inferred extensions.

E.g. `node-dev test/main` should work.
  • Loading branch information...
commit 2ea2c11f612a1f8101dfe36b012d31aa8c1c2753 1 parent 400cfeb
@aseemk aseemk authored
Showing with 9 additions and 1 deletion.
  1. +7 −0 test/main.js
  2. +2 −1  wrapper.js
View
7 test/main.js
@@ -0,0 +1,7 @@
+// Try running this as `node-dev main` instead of `node-dev main.js`:
+if (module !== require.main) {
+ console.error('Expected to be the main module; not the case.')
+ process.exit(1);
+} else {
+ process.exit(0);
+}
View
3  wrapper.js
@@ -8,6 +8,7 @@ var fs = require('fs')
, vm = require('vm')
, spawn = require('child_process').spawn
, clearScreen = /true|yes|on|1/i.test(process.env.NODE_DEV_CLEARSCREEN)
+ , wrapper = module // Save a reference to this module
// Remove wrapper.js from the argv array
process.argv.splice(1, 1)
@@ -110,7 +111,7 @@ var origs = {}
function createHook(ext) {
return function(module, filename) {
- if (module.id == main) {
+ if (module.parent == wrapper) {
// If the main module is required conceal the wrapper
module.id = '.'
module.parent = null
Please sign in to comment.
Something went wrong with that request. Please try again.