-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from back2dos/overhaul
Overhaul
- Loading branch information
Showing
17 changed files
with
268 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"version": "3.4.7", | ||
"version": "4.0.5", | ||
"resolveLibs": "scoped" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-lib travix | ||
-lib hxnodejs | ||
-main travix.Travix | ||
-js bin/run.js | ||
|
||
-lib tink_cli | ||
--no-traces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-D hxnodejs=6.9.1 | ||
# @install: lix --silent download "gh://github.com/haxefoundation/hxnodejs#974f456cfa90c0ca1cc92681eca8665e40b4ab1f" into hxnodejs/6.9.1/github/974f456cfa90c0ca1cc92681eca8665e40b4ab1f | ||
-cp ${HAXE_LIBCACHE}/hxnodejs/6.9.1/github/974f456cfa90c0ca1cc92681eca8665e40b4ab1f/src | ||
-D hxnodejs=10.0.0 | ||
# @install: lix --silent download "haxelib:/hxnodejs#10.0.0" into hxnodejs/10.0.0/haxelib | ||
-cp ${HAXE_LIBCACHE}/hxnodejs/10.0.0/haxelib/src | ||
--macro allowPackage('sys') | ||
# should behave like other target defines and not be defined in macro context | ||
--macro define('nodejs') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# @install: lix --silent download "haxelib:tink_chunk#0.2.0" into tink_chunk/0.2.0/haxelib | ||
-D tink_chunk=0.2.0 | ||
-cp ${HAXESHIM_LIBCACHE}/tink_chunk/0.2.0/haxelib/src | ||
-D tink_chunk=0.3.1 | ||
# @install: lix --silent download "haxelib:/tink_chunk#0.3.1" into tink_chunk/0.3.1/haxelib | ||
-cp ${HAXE_LIBCACHE}/tink_chunk/0.3.1/haxelib/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# @install: lix --silent download "haxelib:tink_core#1.16.1" into tink_core/1.16.1/haxelib | ||
-D tink_core=1.16.1 | ||
-cp ${HAXESHIM_LIBCACHE}/tink_core/1.16.1/haxelib/src | ||
-D tink_core=1.24.0 | ||
# @install: lix --silent download "haxelib:/tink_core#1.24.0" into tink_core/1.24.0/haxelib | ||
-cp ${HAXE_LIBCACHE}/tink_core/1.24.0/haxelib/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-D tink_io=0.6.2 | ||
# @install: lix --silent download "gh://github.com/haxetink/tink_io#9ad28aefacad69c4415d8a458c1a1e920052560e" into tink_io/0.6.2/github/9ad28aefacad69c4415d8a458c1a1e920052560e | ||
-D tink_io=0.7.1 | ||
# @install: lix --silent download "haxelib:/tink_io#0.7.1" into tink_io/0.7.1/haxelib | ||
-lib tink_chunk | ||
-lib tink_streams | ||
-cp ${HAXE_LIBCACHE}/tink_io/0.6.2/github/9ad28aefacad69c4415d8a458c1a1e920052560e/src | ||
-cp ${HAXE_LIBCACHE}/tink_io/0.7.1/haxelib/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# @install: lix --silent download "https://github.com/haxetink/tink_streams/archive/a38e3a97e8512830b31f1fe9476a752cf6fb51ff.tar.gz" into tink_streams/0.2.1/github/a38e3a97e8512830b31f1fe9476a752cf6fb51ff | ||
-D tink_streams=0.2.1 | ||
-cp ${HAXESHIM_LIBCACHE}/tink_streams/0.2.1/github/a38e3a97e8512830b31f1fe9476a752cf6fb51ff/src | ||
-D tink_streams=0.3.2 | ||
# @install: lix --silent download "haxelib:/tink_streams#0.3.2" into tink_streams/0.3.2/haxelib | ||
-lib tink_core | ||
-cp ${HAXE_LIBCACHE}/tink_streams/0.3.2/haxelib/src | ||
# temp for development, delete this file when pure branch merged | ||
-D pure | ||
-lib tink_core | ||
-D pure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# @run: haxelib run-dir travix . | ||
-cp src | ||
-lib tink_cli | ||
-lib hx3compat | ||
-D travix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package travix; | ||
|
||
using tink.CoreApi; | ||
using StringTools; | ||
using haxe.io.Path; | ||
|
||
typedef CommandResult = { | ||
var code(default, null):Int; | ||
var stdout(default, null):String; | ||
var stderr(default, null):String; | ||
} | ||
|
||
class Os { | ||
static public var isWindows(default, never):Bool = Sys.systemName() == 'Windows'; | ||
static public function force<T>(o:Outcome<T, Error>) | ||
return switch o { | ||
case Success(v): v; | ||
case Failure(e): | ||
Sys.println(e.message); | ||
Sys.exit(e.code); | ||
throw 'unreachable'; | ||
} | ||
/** | ||
* Attempts to run a command. | ||
* - results in failure if process creation fails | ||
* - otherwise results in success (even for non-zero exit codes) | ||
*/ | ||
static public function cmdResult(cmd:String, ?args:Array<String>):Outcome<CommandResult, Error> | ||
return try { | ||
#if (hxnodejs && !macro) | ||
var ret = js.node.ChildProcess.spawnSync(cmd, args); | ||
function str(buf:js.node.Buffer) | ||
return buf.toString(); | ||
Success({ | ||
code: ret.status, | ||
stdout: str(ret.stdout), | ||
stderr: str(ret.stderr), | ||
}); | ||
#else | ||
var p = new sys.io.Process(cmd, args); | ||
|
||
function str(buf:haxe.io.Input) | ||
return buf.readAll().toString(); | ||
|
||
Success({ | ||
code: p.exitCode(), | ||
stdout: str(p.stdout), | ||
stderr: str(p.stderr), | ||
}); | ||
#end | ||
} | ||
catch (e:Dynamic) { | ||
Failure(Error.withData(404, 'could not run `$cmd ${args.join(" ")}`', e)); | ||
} | ||
|
||
/** | ||
* Runs a command and returns stdout if process successfully terminated with code 0. | ||
*/ | ||
static public function cmdOutput(cmd:String, args:Array<String>):Outcome<String, Error> | ||
return | ||
switch cmdResult(cmd, args) { | ||
case Success({ code: 0, stdout: v }): Success(v); | ||
case Success(d = { code: code, stderr: v }): | ||
Failure(Error.withData(code, 'The command `$cmd ${args.join(" ")}` exited with code $code', d)); | ||
case Failure(e): Failure(e); | ||
} | ||
|
||
static public function which(cmd:String) { | ||
return switch cmdOutput(isWindows ? 'where' : 'which', [cmd]) { | ||
case Failure(e): Failure(e); | ||
case Success(out) if (isWindows): | ||
var ret = Failure(new Error(404, 'could not find $cmd')); | ||
for (l in out.split('\n')) | ||
switch l.trim() { | ||
case _.extension() => null | '': | ||
case v: | ||
ret = Success(v); | ||
break; | ||
} | ||
ret; | ||
case Success(out): Success(out.split('\n')[0]); | ||
} | ||
} | ||
} |
Oops, something went wrong.