fix c9 cli not working with npm 3

pull/272/head
nightwing 2016-03-09 22:36:19 +04:00
rodzic 65bb088557
commit 30df2c6cba
1 zmienionych plików z 18 dodań i 0 usunięć

18
bin/c9
Wyświetl plik

@ -1,5 +1,23 @@
#!/usr/bin/env node
// workaround for npm 3 breaking bundled dependencies
if (Module.REPLACE_NODE_MODULE_PATH) {
var Module = require("module");
var path = require("path")
var _resolveFilename_orig = Module._resolveFilename
Module._resolveFilename = function(id, parent) {
var root = path.join(__dirname, "/..");
if (parent && parent.paths && parent.paths[0] && parent.paths[0].indexOf(root) == 0) {
parent.paths = parent.paths.map(function(p) {
if (p.indexOf(root) != 0) return
p = p.slice(root.length);
return root + p.replace(/([\\\/]|^)node_modules([\\\/]|$)/g, "$1n_m$2");
}).filter(Boolean);
}
return _resolveFilename_orig.call(Module, id, parent);
};
}
// Architect
var architect = require("architect");