Skip to content

Commit

Permalink
--link-program-to option
Browse files Browse the repository at this point in the history
boot: false in program.json
  • Loading branch information
cadorn committed Aug 23, 2011
1 parent 2a9f62e commit ab2748e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/pinf-loader-js/descriptors.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ Program.prototype.walkBoot = function(callback)
{
if (typeof this.json.boot == "undefined")
throw this.validationError("Property 'boot' is not defined");
if (typeof this.json.boot == "boolean") {
if (this.json.boot !== false)
throw this.validationError("Property 'boot' must be set to a string or `false`");
callback(false);
} else
if (typeof this.json.boot == "string")
callback(this._validateBoot(this.json.boot));
else
Expand Down
23 changes: 23 additions & 0 deletions lib/pinf-loader-js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ var boot = exports.boot = function(options)
optParser.option("--test-platform").set().help("Make sure a platform is working properly");
optParser.option("--sources").set().help("The path to a sources.json file to overlay source repositories");
optParser.option("--script").set().help("Call a script defined in the program boot package");
optParser.option("--link-program-to").set().help("Link the program package to the given directory");
optParser.option("--discover-packages").bool().help("Discover all packages and add to program.json");
optParser.option("--clean").bool().help("Removes all downloaded packages first");
optParser.option("--terminate").bool().help("Asks program to terminate if it was going to deamonize (primarily used for testing)");
Expand Down Expand Up @@ -287,6 +288,23 @@ var boot = exports.boot = function(options)
}

downloader.basePath = pinfPackagesPath;


if (cliOptions["link-program-to"])
{
if (!API.FILE.exists(cliOptions["link-program-to"]))
{
if (!API.FILE.exists(API.FILE.dirname(cliOptions["link-program-to"])))
API.FILE.mkdirs(API.FILE.dirname(cliOptions["link-program-to"]), 0775);

API.SYSTEM.exec("ln -s " + API.FILE.dirname(path) + " " + cliOptions["link-program-to"], function(stdout, stderr)
{
console.log(stdout);
console.log(stderr);
});
}
}


API.DEBUG.print("Using program cache directory: " + downloader.basePath);

Expand Down Expand Up @@ -379,6 +397,11 @@ var boot = exports.boot = function(options)
// TODO: Keep these references elsewhere so we can have nested sandboxes
API.ENV.program = program;
API.ENV.sandbox = sandbox;

if (!program.hasBootPackage())
{
return;
}

program.getBootPackages(assembler, function(dependencies)
{
Expand Down
9 changes: 8 additions & 1 deletion lib/pinf-loader-js/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Program.prototype.discoverPackages = function(fetcher, callback, options)
var self = this;
self.descriptor.walkBoot(function(id)
{
DEBUG.indent(di).print("ID: " + id).indent(di+1);
DEBUG.indent(di).print("ID: " + id).indent(di+1);

if (id === false) return;

fetcher(self.descriptor.locatorForId(id, options), cbt.add(function(pkg, locator)
{
Expand All @@ -50,6 +52,11 @@ Program.prototype.discoverPackages = function(fetcher, callback, options)
cbt.done();
}

Program.prototype.hasBootPackage = function()
{
return (this.descriptor.json.boot!==false)?true:false;
}

Program.prototype.getProviderPackages = function()
{
var self = this,
Expand Down

0 comments on commit ab2748e

Please sign in to comment.