Skip to content

Commit dcea134

Browse files
Remove the dummy binary and simplify the distribution
1 parent de46e67 commit dcea134

File tree

6 files changed

+47
-10
lines changed

6 files changed

+47
-10
lines changed

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ git-cache-http-server --port 1234 --cache-dir /tmp/cache/git &
3131
git clone http://localhost:1234/github.com/jonasmalacofilho/git-cache-http-server
3232
```
3333

34-
If you run your git-cache on a dedicated server or container (i.e. named gitcache), you can then also configure git to always use your cache like in the following example (don't use this configuration on the git-cache machine itself):.
34+
If you run your git-cache on a dedicated server or container (i.e. named
35+
gitcache), you can then also configure git to always use your cache like in the
36+
following example (don't use this configuration on the git-cache machine
37+
itself):.
38+
3539
```
3640
git config --global url."http://gitcache:1234/".insteadOf https://
3741
```
@@ -40,7 +44,7 @@ git config --global url."http://gitcache:1234/".insteadOf https://
4044

4145
Requirements: `nodejs` and `git`.
4246

43-
Install: `npm install -g git-cache-http-server`
47+
Install: `npm install --global git-cache-http-server`.
4448

4549
To install as a service, check the `doc/git-cache-http-server.service` example
4650
service file.
@@ -54,18 +58,23 @@ systemctl daemon-reload
5458
systemctl start git-cache-http-server
5559
```
5660

57-
# Building from source
61+
# Working on the sources
5862

59-
This is needed only if you change the Haxe source code in `src/`.
63+
This is only needed if you want to change the Haxe source code in `src/`.
6064

61-
Requirements: [Haxe](https://haxe.org) (`haxe` and `haxelib`). If you prefer to manage the build dependencies manually, check out [`build.hxml`](build.hxml) for the required libraries.
65+
Requirements: [Haxe](https://haxe.org) (`haxe` and `haxelib`). If you prefer
66+
to manage the build dependencies manually, check out [`build.hxml`](build.hxml)
67+
for the required libraries.
6268

6369
```
6470
haxelib newrepo
6571
haxelib install build.hxml
6672
haxe build.hxml
6773
```
6874

75+
And in order to use the locally modified version: `npm link` (this changes the
76+
global NPM space).
77+
6978
# Implementation
7079

7180
The current implementation is somewhat oversimplified; any help in improving it

bin/git-cache-http-server

Lines changed: 0 additions & 3 deletions
This file was deleted.

bin/git-cache-http-server.js

100644100755
Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.hxml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
-cp src
44
-lib hxnodejs
55
-lib jmf-npm-externs:git:https://github.com/jonasmalacofilho/jmf-npm-externs.hx#master
6+
--macro BuildUtils.addShebang("/usr/bin/env", "node")
7+
--macro BuildUtils.makeExecutable()

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "0.0.2",
44
"description": "A caching Git HTTP server",
55
"bin": {
6-
"git-cache-http-server": "bin/git-cache-http-server"
6+
"git-cache-http-server": "./bin/git-cache-http-server.js"
77
},
8-
"main": "bin/git-cache-http-server.js",
8+
"main": "./bin/git-cache-http-server.js",
99
"directories": {
1010
"doc": "doc",
1111
"src": "src"

src/BuildUtils.hx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import haxe.macro.Compiler;
2+
import haxe.macro.Context;
3+
import sys.io.File;
4+
5+
class BuildUtils {
6+
public static function addShebang(interpreter:String, ?arg:String) {
7+
// implementation borrowed from travix
8+
// https://github.com/back2dos/travix
9+
// licensed under the The Unlicense
10+
Context.onAfterGenerate(function() {
11+
var out = Compiler.getOutput();
12+
File.saveContent(out, '#!$interpreter $arg\n\n' + File.getContent(out));
13+
});
14+
}
15+
16+
public static function makeExecutable()
17+
{
18+
if (Sys.systemName() == "Windows")
19+
return;
20+
Context.onAfterGenerate(function() {
21+
var out = Compiler.getOutput();
22+
if (Sys.command("chmod", ["+x", out]) != 0)
23+
Context.error("chmod +x failed", Context.currentPos());
24+
});
25+
}
26+
}
27+

0 commit comments

Comments
 (0)