Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 46 lines (40 sloc) 1.126 kb
33f39c3 @indexzero [api test] Update requireish to use new processes to circumvent the M…
indexzero authored
1 #!/usr/bin/env node
2
3 var Module = require('module').Module,
4 __load = Module._load,
5 packages = {};
6
7 //
8 // Monkey punch `Module._load()` to observe the names
05d6dd3 @fat display full path of file if not a package.
fat authored
9 // of packages as they are loaded.
33f39c3 @indexzero [api test] Update requireish to use new processes to circumvent the M…
indexzero authored
10 //
05d6dd3 @fat display full path of file if not a package.
fat authored
11 Module._load = function (name, parent) {
86e9cdf @fb55 use `detective` per default and only create a thread when it doesn't …
fb55 authored
12 process.send({type: "load", msg: name});
13 if(name[0] === "." || name[0] === "/"){
14 name = Module._resolveFilename(name, parent)[1];
15 }
33f39c3 @indexzero [api test] Update requireish to use new processes to circumvent the M…
indexzero authored
16 return __load.apply(Module, arguments);
86e9cdf @fb55 use `detective` per default and only create a thread when it doesn't …
fb55 authored
17 };
33f39c3 @indexzero [api test] Update requireish to use new processes to circumvent the M…
indexzero authored
18
05d6dd3 @fat display full path of file if not a package.
fat authored
19 try {
ab343d1 @indexzero [fix] `process.nextTick()` exit in find-dependencies based on comment…
indexzero authored
20 process.nextTick(function () {
21 process.exit(0);
22 });
c157bc3 @indexzero [fix] Respond to callback with error on `childError` events
indexzero authored
23
86e9cdf @fb55 use `detective` per default and only create a thread when it doesn't …
fb55 authored
24 __load.call(Module, process.argv[2], null, true);
33f39c3 @indexzero [api test] Update requireish to use new processes to circumvent the M…
indexzero authored
25 }
26 catch (ex) {
27 //
ba57948 @indexzero [api test] If errors are returned from a child_process, inform the us…
indexzero authored
28 // Log errors and attempt to log as many packages as we can.
33f39c3 @indexzero [api test] Update requireish to use new processes to circumvent the M…
indexzero authored
29 //
256aefc @dominictarr fix response to error states. (stack over flow and falsey errors wher…
dominictarr authored
30 var eStr = '' + (ex
623cf13 @AvianFlu [bin] Added node-detective fallback on require errors.
AvianFlu authored
31 ? (ex.stack ? ex.stack : ex)
86e9cdf @fb55 use `detective` per default and only create a thread when it doesn't …
fb55 authored
32 : 'falsey error: ' + ex);
256aefc @dominictarr fix response to error states. (stack over flow and falsey errors wher…
dominictarr authored
33
a76843f @AvianFlu [bin] Fix for require-only dependency detection.
AvianFlu authored
34 //
35 // However, 'cannot find module' errors should be squashed.
36 // In cases with no node_modules present, this is not an indication of failure.
37 // This should perhaps be replaced with a node-detective fallback.
38 //
39
86e9cdf @fb55 use `detective` per default and only create a thread when it doesn't …
fb55 authored
40 if (!("code" in ex
41 ? ex.code === "MODULE_NOT_FOUND"
42 : /^Error: Cannot find module '.*'/.test(eStr))
43 ) {
44 process.send({type: "error", msg: eStr});
a76843f @AvianFlu [bin] Fix for require-only dependency detection.
AvianFlu authored
45 }
33f39c3 @indexzero [api test] Update requireish to use new processes to circumvent the M…
indexzero authored
46 }
Something went wrong with that request. Please try again.