Permalink
Browse files

central /pinf/pinf_packages; versiond program sandboxes for npm; node…

… 0.4 compatibility
  • Loading branch information...
1 parent a5dffe5 commit 2a9f62e958d0cc9243e5f5c790efdf55e911fa78 @cadorn cadorn committed Aug 23, 2011
Showing with 24 additions and 13 deletions.
  1. +2 −2 docs/Setup.md
  2. +5 −3 lib/pinf-loader-js/adapter/node.js
  3. +4 −4 lib/pinf-loader-js/assembler.js
  4. +13 −4 lib/pinf-loader-js/loader.js
View
4 docs/Setup.md
@@ -11,8 +11,8 @@ UNIX file paths are expected and no testing has been done on Windows.
Compatibility
-------------
- * `0.1.x` requires NodeJS `0.4.x`
- * `0.2.x` requires NodeJS `>= 0.5` and NPM `>= 1.0.24`
+ * `0.1.x` is compatible with NodeJS `<= 0.4`
+ * `0.2.x` is compatible with NodeJS `>= 0.4`
Loader Code
View
8 lib/pinf-loader-js/adapter/node.js
@@ -25,15 +25,17 @@ exports.init = function(api)
// JSON = provided by nodejs as a global
// setTimeout = provided by nodejs as a global
+/*
if (process.version.match(/^v?(\d*\.\d*)/)[1] < 0.5)
{
throw new Error("NodeJS version 0.5+ required as of PINF Loader 0.2!");
}
+*/
// TEMPORARY: http://stackoverflow.com/questions/5919629/express-module-not-found-when-installed-with-npm
-// if (/^v?0\.4/.test(process.version)) {
-// api.ENV.platformRequire.paths.push('/usr/local/lib/node_modules');
-// }
+ if (/^v?0\.4/.test(process.version)) {
+ api.ENV.platformRequire.paths.push('/usr/local/lib/node_modules');
+ }
api.ENV.loaderRoot = PATH.dirname(PATH.dirname(PATH.dirname(PATH.dirname(__filename))));
View
8 lib/pinf-loader-js/assembler.js
@@ -32,11 +32,11 @@ Assembler.prototype.pmLocatorResolver = function(program, locator, callback)
{
rootProgramPath = FILE.dirname(program.descriptor.path);
}
-
- var sandboxPath = FILE.realpath("/pinf/cache/github.com/pinf/loader-js/-npm-sandboxes/" + rootProgramPath),
+
+ var sandboxPath = FILE.realpath("/pinf/cache/github.com/pinf/loader-js/-npm-sandboxes/" + rootProgramPath + ((program.descriptor.json.version)?"/"+program.descriptor.json.version:"")),
pkgPath = sandboxPath + "/node_modules/" + locator.name;
- if (!FILE.exists(sandboxPath))
- FILE.mkdirs(sandboxPath, 0775);
+ if (!FILE.exists(sandboxPath + "/node_modules"))
+ FILE.mkdirs(sandboxPath + "/node_modules", 0775);
locator.location = pkgPath;
View
17 lib/pinf-loader-js/loader.js
@@ -191,10 +191,14 @@ var boot = exports.boot = function(options)
API.DEBUG.print("----------------------------------------------------------------------------\0)");
API.DEBUG.print("Loaded adapter: " + API.ENV.platform);
-
+
+ var pinfPackagesPath = "/pinf/pinf_packages";
+ if (!API.FILE.exists(pinfPackagesPath)) {
+ pinfPackagesPath = API.SYSTEM.pwd + "/.pinf-packages";
+ }
+
var downloader = new ((API.DOWNLOADER = require("./downloader")).Downloader)({
- // TODO: Look for a better place first
- basePath: API.SYSTEM.pwd + "/.pinf-packages"
+ basePath: pinfPackagesPath
});
var assembler = API.ENV.assembler = new (require("./assembler").Assembler)(downloader);
@@ -277,7 +281,12 @@ var boot = exports.boot = function(options)
API.DEBUG.print("Loading program descriptor from: " + path);
- downloader.basePath = path.substring(0, path.length-13) + "/.pinf-packages";
+ var pinfPackagesPath = "/pinf/pinf_packages";
+ if (!API.FILE.exists(pinfPackagesPath)) {
+ pinfPackagesPath = path.substring(0, path.length-13) + "/.pinf-packages";
+ }
+
+ downloader.basePath = pinfPackagesPath;
API.DEBUG.print("Using program cache directory: " + downloader.basePath);

0 comments on commit 2a9f62e

Please sign in to comment.