Skip to content

Commit

Permalink
Use HAXELIB_RUN env instead of modifying run
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Lemière committed Mar 11, 2016
1 parent a41d46b commit 6dfb49b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/haxelib/client/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class Main {
{
args = Sys.args();

if (Sys.getEnv("HAXELIB_RUN") == "1") {
Sys.setCwd(args.pop());
}

commands = new List();
addCommand("install", install, "install a given library, or all libraries from a hxml file", Basic);
addCommand("update", update, "update a single library (if given) or all installed libraries", Basic);
Expand Down Expand Up @@ -348,18 +352,16 @@ class Main {
}
}

if (!settings.safe && FileSystem.exists(getRepository() + "haxelib_client")) {
if ((!settings.safe && Sys.getEnv("HAXELIB_RUN") != "1") && FileSystem.exists(getRepository() + "haxelib_client")) {
var old_argcur = argcur;
argcur = 0; // send all arguments
args.unshift("--safe");

try {
doRun("haxelib_client", null, false);
doRun("haxelib_client", null);
} catch (e:String) {
if (e.startsWith("Library haxelib_client version ") && e.endsWith(" does not have a run script")) {
// old version of haxelib_client without run script, ignore
argcur = old_argcur;
args.shift();
} else {
throw e;
}
Expand Down Expand Up @@ -1374,7 +1376,7 @@ class Main {
doRun(temp[0], temp[1]);
}

function doRun( project:String, version:String, changeDir=true ) {
function doRun( project:String, version:String ) {
var rep = getRepository();
var pdir = rep + Data.safe(project);
if( !FileSystem.exists(pdir) )
Expand All @@ -1391,10 +1393,8 @@ class Main {
catch (e:Dynamic)
throw 'Error parsing haxelib.json for $project@$version: $e';

if (changeDir) {
args.push(Sys.getCwd());
Sys.setCwd(vdir);
}
args.push(Sys.getCwd());
Sys.setCwd(vdir);

var callArgs =
if (infos.main == null) {
Expand Down

1 comment on commit 6dfb49b

@nadako
Copy link
Member

@nadako nadako commented on 6dfb49b Mar 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, don't check HAXELIB_RUN against value "1", just do != null instead. I hope we'll change this env var to contain a library directory path someday (#272).

Please sign in to comment.