diff --git a/bin/elm-test b/bin/elm-test index 6dfd0227..26746261 100755 --- a/bin/elm-test +++ b/bin/elm-test @@ -49,8 +49,9 @@ if (process.argv[2] == "init") { process.exit(0); } -var testFile = process.argv[2], - cwd = __dirname; +var testFile = process.argv[2], + cwd = __dirname, + pathToMake = undefined; function spawnCompiler(cmd, args, opts) { var compilerOpts = _.defaults({stdio: ["inherit", "pipe", "inherit"]}, opts); @@ -60,7 +61,7 @@ function spawnCompiler(cmd, args, opts) { if (typeof testFile !== "string") { console.log("Usage: elm-test init [--yes] # Create example tests\n"); - console.log("Usage: elm-test TESTFILE # Run tests\n"); + console.log("Usage: elm-test TESTFILE [--compiler /path/to/compiler] # Run tests\n"); process.exit(1); } @@ -69,18 +70,27 @@ if (!fs.existsSync(testFile)) { process.exit(1); } +if (process.argv[3] == "--compiler" || process.argv[3] == "-c") { + pathToMake = process.argv[4]; + + if (!pathToMake) { + console.error("The --compiler option must be given a path to an elm-make executable."); + process.exit(1); + } +} + temp.open({ prefix:'elm_test_', suffix:'.js' }, function(err, info) { var dest = info.path; - var compileProcess = compile([testFile], {output: dest, spawn: spawnCompiler}); - - console.log("Compiling", testFile); + var compileProcess = compile( [testFile], + {output: dest, spawn: spawnCompiler, pathToMake: pathToMake}); compileProcess.stdout.setEncoding("utf8") compileProcess.stdout.on("data", function(data) { // Explicitly strip out the "Successfully generated" message. // This avoids the nasty compiler output message for the temp file, e.g. // "Successfully generated /var/folders/f2/afd9fg0acfg32/elm_test_3423940" - if ((typeof data === "string") && !data.match(/^Successfully generated /)) { + // Also strip out "Success! Compiled 1 module." + if ((typeof data === "string") && !/^Success/.test(data)) { console.log(data); } }); diff --git a/package.json b/package.json index c21db60d..a602f5d0 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,9 @@ }, "homepage": "https://github.com/rtfeldman/node-elm-test#readme", "dependencies": { - "fs-extra": "0.23.1", + "fs-extra": "0.26.2", "lodash": "3.10.1", - "node-elm-compiler": "1.0.1", - "temp": "0.8.1" + "node-elm-compiler": "2.0.0", + "temp": "0.8.3" } }