Skip to content

Keep scope when calling haxe cli from haxelib run #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/haxeshim/HaxeInstallation.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ class HaxeInstallation {
static var EXT = if (Os.IS_WINDOWS) '.exe' else '';

public var path(default, null):String;
public var scope(default, null):String;
public var stdLib(default, null):String;
public var compiler(default, null):String;
public var haxelib(default, null):String;
public var version(default, null):String;
public var haxelibRepo(default, null):String;

public function new(path:String, version:String, haxelibRepo:String) {
public function new(path:String, version:String, haxelibRepo:String, scope:String) {
this.path = path;
this.version = version;
this.compiler = '$path/haxe$EXT';
this.haxelib = '$path/haxelib$EXT';
this.stdLib = '$path/std';
this.haxelibRepo = haxelibRepo;
this.scope = scope;
}

public function env():Env {
Expand All @@ -25,6 +27,7 @@ class HaxeInstallation {
HAXEPATH: path,
HAXELIB_PATH: haxelibRepo,
HAXE_VERSION: version,
SCOPE_PATH: scope
}

return ret.mergeInto(Neko.ENV);
Expand Down
7 changes: 5 additions & 2 deletions src/haxeshim/HaxelibCli.hx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ class HaxelibCli {
}
}

static function main()
new HaxelibCli(Scope.seek()).dispatch(Sys.args());
static function main() {
new HaxelibCli(Scope.seek({
cwd: Sys.getEnv('SCOPE_PATH')
})).dispatch(Sys.args());
}

}
12 changes: 6 additions & 6 deletions src/haxeshim/Scope.hx
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ class Scope {
return
switch path(version) {
case Some(path):
new HaxeInstallation(path, version, haxelibRepo);
new HaxeInstallation(path, version, haxelibRepo, scopeDir);
case None:
new HaxeInstallation('$versionDir/$version', version, haxelibRepo);
new HaxeInstallation('$versionDir/$version', version, haxelibRepo, scopeDir);
}

function resolveThroughHaxelib(libs:Array<String>)
function resolveThroughHaxelib(libs:Array<String>)
return
switch Exec.eval(haxeInstallation.haxelib, cwd, ['path'].concat(libs), haxeInstallation.env()) {
case Success({ status: 0, stdout: stdout }):
Expand Down Expand Up @@ -278,7 +278,7 @@ class Scope {
static public function seek(?options:SeekingOptions) {
if (options == null)
options = {};

var cwd = switch options.cwd {
case null: Sys.getCwd();
case v: v;
Expand All @@ -288,14 +288,14 @@ class Scope {
case null: cwd;
case v: v;
}

var haxeshimRoot = switch options.haxeshimRoot {
case null: DEFAULT_ROOT;
case v: v;
}

var make = Scope.new.bind(haxeshimRoot, _, _, cwd);

var ret = switch Fs.findNearest(CONFIG_FILE, startLookingIn.absolutePath()) {
case Some(v): make(false, v.directory());
case None: make(true, haxeshimRoot);
Expand Down