From bf933126554353a9c1ec83906d710be7cdf55851 Mon Sep 17 00:00:00 2001
From: impinball <impinball@gmail.com>
Date: Sat, 2 Jan 2016 10:17:46 -0500
Subject: [PATCH] Use node to run eslc binary

Step 1 for making this buildable in Windows.
---
 bin/eslc                      | 15 ---------------
 bin/eslc.js                   |  3 +++
 doc/basics-reference.markdown |  2 +-
 doc/how-macros-work.markdown  |  2 +-
 package.json                  |  2 +-
 readme.markdown               |  2 +-
 test.ls                       |  4 ++--
 7 files changed, 9 insertions(+), 21 deletions(-)
 delete mode 100755 bin/eslc
 create mode 100644 bin/eslc.js

diff --git a/bin/eslc b/bin/eslc
deleted file mode 100755
index 5ddd998..0000000
--- a/bin/eslc
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env node
-
-/*
-This is just a wrapper that loads the actual compiled source from `../lib`.
-
-Why?  Because compiling everything to over there is much simpler to organise,
-and this file can just stay constant.
-*/
-
-var path = require("path");
-var fs   = require("fs");
-
-var lib  = path.join(path.dirname(fs.realpathSync(__filename)), "../lib");
-
-require(lib + "/cli");
diff --git a/bin/eslc.js b/bin/eslc.js
new file mode 100644
index 0000000..6105f28
--- /dev/null
+++ b/bin/eslc.js
@@ -0,0 +1,3 @@
+#!/usr/bin/env node
+// Simple wrapper script for src/cli.ls, independent of the build system.
+require("../lib/cli")
diff --git a/doc/basics-reference.markdown b/doc/basics-reference.markdown
index 9fbe8e4..ff52d53 100644
--- a/doc/basics-reference.markdown
+++ b/doc/basics-reference.markdown
@@ -66,7 +66,7 @@ those later.)
 
 ## Compilation
 
-<!-- !test program ./bin/eslc | head -c -1 -->
+<!-- !test program node ./bin/eslc.js | head -c -1 -->
 
 When you hand your code to the eslisp compiler, it reads the lists and turns
 them into JavaScript code with the following rules:
diff --git a/doc/how-macros-work.markdown b/doc/how-macros-work.markdown
index 9dd8604..80a2ef8 100644
--- a/doc/how-macros-work.markdown
+++ b/doc/how-macros-work.markdown
@@ -5,7 +5,7 @@ differently, but call them the same way as normal functions.  They can execute
 whatever logic you want, and their return values become program code at the
 point where they're called.
 
-<!-- !test program ./bin/eslc | head -c -1 -->
+<!-- !test program node ./bin/eslc.js | head -c -1 -->
 
 ## The basics
 
diff --git a/package.json b/package.json
index d4ef124..2ffaaa9 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
     "doc": "./doc"
   },
   "bin": {
-    "eslc": "./bin/eslc"
+    "eslc": "./bin/eslc.js"
   },
   "files": [
     "lib",
diff --git a/readme.markdown b/readme.markdown
index 422c756..d578704 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -11,7 +11,7 @@ your own language features, [like this][9].
 > :warning: **Note the 0.x.x [semver][10].**  The API may shift under your
 > feet.
 
-<!-- !test program ./bin/eslc | head -c -1 -->
+<!-- !test program node ./bin/eslc.js | head -c -1 -->
 
 <!-- !test in fib -->
 
diff --git a/test.ls b/test.ls
index d1e4178..e26cb66 100755
--- a/test.ls
+++ b/test.ls
@@ -872,9 +872,9 @@ test "macros can be required relative to root directory" ->
     (x)
     """
 
-  eslc-path = path.join process.cwd!, "bin/eslc"
+  eslc-path = path.join __dirname, "bin/eslc.js"
   try
-    exec-sync "#eslc-path #main-basename", cwd : dir-name
+    exec-sync "node #eslc-path #main-basename", cwd : dir-name
       ..to-string! `@equals` "\n"
   finally
     e <~ rimraf dir-name