Merge pull request +8012 from c9/profile-require

Allow portable paths in profile require()
pull/117/merge
Matthijs van Henten 2015-06-29 11:10:03 +02:00
commit 2025a19647
4 zmienionych plików z 24 dodań i 1 usunięć

Wyświetl plik

@ -6,4 +6,5 @@ build/webkitbuilds/
build/win32*
build/Cloud9
build/sdk
node_modules/logicblox/build/logicblox/static
node_modules/logicblox/build/logicblox/static
plugins/c9/profile/dist/bundle.js

20
node_modules/c9/setup_paths.js wygenerowano vendored 100644
Wyświetl plik

@ -0,0 +1,20 @@
/**
* Allow code that lives on the server to resolve paths like
* require("plugins/c9.language/language"),
* just like on the client.
*/
var modules = require("module");
var oldResolve = modules._resolveFilename;
var extraPaths = [
__dirname + "/../../"
];
modules._resolveFilename = function(request, paths) {
// Ensure client extensions can be loaded
request = request.replace(/^lib\//, "node_modules/");
// Add the extra paths
extraPaths.forEach(function(p) {
if(paths.paths.indexOf(p) === -1)
paths.paths.push(p);
});
return oldResolve(request, paths);
};

Wyświetl plik

@ -2,6 +2,7 @@
"use strict";
require("amd-loader");
require("c9/setup_paths.js");
var path = require("path");
var architect = require("architect");
var optimist = require("optimist");

Wyświetl plik

@ -11,6 +11,7 @@ var architect = require("architect");
var optimist = require("optimist");
var async = require("async");
var os = require("os");
require("c9/setup_paths.js");
if (process.version.match(/^v0/) && parseFloat(process.version.substr(3)) < 10) {
console.warn("You're using Node.js version " + process.version