defunctzombie / node-required

identifies which modules your script is using
67 stars 15 forks source link

Conditional require() not handled #8

Closed matthewgertner closed 10 years ago

matthewgertner commented 10 years ago

For example, I get an error in CoffeeScript's parser.js:

    if (typeof process !== 'undefined') {
        var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
    } else {
        var cwd = require("file").path(require("file").cwd());
        var source = cwd.join(args[1]).read({charset: "utf-8"});
    }

It tries to find a 'file' module even though it is running Node.js and should use only the moduled required in the if clause:

Fatal error: /Users/matthewgertner/.../node_modules/grunt/node_modules/coffee-script/lib/coffee-script/parser.js: Cannot call method 'push' of undefined