Skip to content

Commit

Permalink
look for .haxelib recursively up along the dir tree
Browse files Browse the repository at this point in the history
closes #292
  • Loading branch information
RealyUniqueName committed Sep 16, 2019
1 parent a3e2f64 commit 25a8ff4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Binary file modified run.n
Binary file not shown.
22 changes: 20 additions & 2 deletions src/haxelib/client/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,12 +1160,30 @@ class Main {
}

function getRepository():String {
if (!settings.global && FileSystem.exists(REPODIR) && FileSystem.isDirectory(REPODIR))
return Path.addTrailingSlash(FileSystem.fullPath(REPODIR));
if (!settings.global)
return switch getLocalRepository() {
case null: getGlobalRepository();
case repo: Path.addTrailingSlash(FileSystem.fullPath(repo));
}
else
return getGlobalRepository();
}

function getLocalRepository():Null<String> {
function lookup(path:Path):Null<String> {
var repo = path.toString() + '/' + REPODIR;
trace(repo);

This comment has been minimized.

Copy link
@Aurel300

Aurel300 Sep 16, 2019

Member

Leftover from debugging?

if(FileSystem.exists(repo) && FileSystem.isDirectory(repo)) {
return repo;
} else {
var dir = path.dir;
return dir == null ? null : lookup(new Path(dir));

This comment has been minimized.

Copy link
@Aurel300

Aurel300 Sep 16, 2019

Member

You write Haxe like it's OCaml :) (recursion)

This comment has been minimized.

Copy link
@Simn

Simn Sep 16, 2019

Member

Eventually he'll implement tail-call elimination to make up for it.

This comment has been minimized.

Copy link
@RealyUniqueName

RealyUniqueName Sep 16, 2019

Author Member

ah, right. Too much ocamling these days...

}
}

return lookup(new Path(Path.removeTrailingSlashes(Sys.getCwd())));
}

function getGlobalRepository():String {
var rep = getGlobalRepositoryPath(true);
if (!FileSystem.exists(rep))
Expand Down
5 changes: 2 additions & 3 deletions www/documentation-files/per-project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ Currently haxelib has two ways to have project local setups.

### Using haxelib newrepo

When using `haxelib newrepo` you can have a project-local haxelib repository.
When using `haxelib newrepo` you can have a project-local haxelib repository.

Caveats:

- libraries get downloaded for each project
- if you mistakenly run a haxelib command in a subdirectory of your project, it will be executed on the global repo ([to be fixed](https://github.com/HaxeFoundation/haxelib/issues/292))

### Using haxelib install all

Expand All @@ -30,7 +29,7 @@ Advantages:

#### Using haxelib with git versions

You can specify git versions with `--library libname:git:https://github.com/user/repo#branch` branch can be a branch or a specific commit SHA.
You can specify git versions with `--library libname:git:https://github.com/user/repo#branch` branch can be a branch or a specific commit SHA.
As alternative, you might use git submodules instead, they also provide an adequate way of definining a *versionable* and *replicable* state.

### Combining both approaches
Expand Down

0 comments on commit 25a8ff4

Please sign in to comment.