node-elm-compiler
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -8,3 +8,3 @@ { | ||
], | ||
"description": "A Node.js interface to the Elm compiler binaries. Supports Elm versions 0.15 - 0.16.", | ||
"description": "A Node.js interface to the Elm compiler binaries. Supports Elm version 0.17", | ||
"main": "index.js", | ||
@@ -11,0 +11,0 @@ "keywords": [ |
@@ -11,5 +11,6 @@ { | ||
"dependencies": { | ||
"elm-lang/core": "2.0.0 <= v < 4.0.0" | ||
"elm-lang/core": "4.0.0 <= v < 5.0.0", | ||
"elm-lang/html": "1.0.0 <= v < 2.0.0" | ||
}, | ||
"elm-version": "0.15.0 <= v < 0.17.0" | ||
"elm-version": "0.17.0 <= v < 0.18.0" | ||
} |
30
index.js
@@ -18,4 +18,6 @@ 'use strict'; | ||
output: undefined, | ||
report: undefined, | ||
warn: undefined, | ||
verbose: false | ||
verbose: false, | ||
processOpts: undefined, | ||
}; | ||
@@ -44,3 +46,3 @@ | ||
var env = _.merge({LANG: 'en_US.UTF-8'}, process.env); | ||
var processOpts = _.merge({env: env, stdio: "inherit", cwd: options.cwd}); | ||
var processOpts = _.merge({ env: env, stdio: "inherit", cwd: options.cwd }, options.processOpts); | ||
var pathToMake = options.pathToMake || compilerBinaryName; | ||
@@ -166,12 +168,22 @@ var verbose = options.verbose; | ||
options.output = info.path; | ||
options.processOpts = { stdio: 'pipe' } | ||
compile(sources, options) | ||
.on("close", function(exitCode){ | ||
fs.readFile(info.path, function(err, data){ | ||
if (exitCode !== 0) { | ||
err = "Compiler process exited with code " + exitCode; | ||
} | ||
var compiler = compile(sources, options); | ||
var output = ''; | ||
compiler.stdout.on('data', function(chunk) { | ||
output += chunk; | ||
}); | ||
compiler.stderr.on('data', function(chunk) { | ||
output += chunk; | ||
}); | ||
compiler.on("close", function(exitCode) { | ||
if (exitCode !== 0) { | ||
temp.cleanupSync(); | ||
return reject(new Error('Compilation failed\n' + output)); | ||
} | ||
fs.readFile(info.path, function(err, data){ | ||
temp.cleanupSync(); | ||
return err ? reject(err) : resolve(data); | ||
@@ -221,2 +233,3 @@ }); | ||
case "output": return ["--output", escapePath(value)]; | ||
case "report": return ["--report", value]; | ||
case "warn": return ["--warn"]; | ||
@@ -238,4 +251,5 @@ default: | ||
compile: compile, | ||
compileWorker: require("./worker.js")(compile), | ||
compileToString: compileToString, | ||
findAllDependencies: findAllDependencies | ||
}; |
{ | ||
"name": "node-elm-compiler", | ||
"version": "3.0.0", | ||
"description": "A Node.js interface to the Elm compiler binaries. Supports Elm versions 0.15 - 0.16.", | ||
"version": "4.0.0", | ||
"description": "A Node.js interface to the Elm compiler binaries. Supports Elm version 0.17", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -5,3 +5,3 @@ # node-elm-compiler [![Version](https://img.shields.io/npm/v/node-elm-compiler.svg)](https://www.npmjs.com/package/node-elm-compiler) [![Travis build Status](https://travis-ci.org/rtfeldman/node-elm-compiler.svg?branch=master)](http://travis-ci.org/rtfeldman/node-elm-compiler) [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/xv83jcomgb81i1iu/branch/master?svg=true)](https://ci.appveyor.com/project/rtfeldman/node-elm-compiler/branch/master) | ||
Supports Elm versions 0.15 - 0.16 | ||
Supports Elm version 0.17 | ||
@@ -18,2 +18,6 @@ # Example | ||
## 4.0.0 | ||
Use an `Error` object for result errors instead of a string. | ||
## 3.0.0 | ||
@@ -20,0 +24,0 @@ |
@@ -68,5 +68,5 @@ var chai = require("chai") | ||
// Use a timeout of 5 minutes because Travis on Linux can be SUPER slow. | ||
this.timeout(3000); | ||
this.timeout(300000); | ||
it("works with --yes", function (done) { | ||
it("works with --yes", function () { | ||
var opts = { | ||
@@ -79,10 +79,9 @@ yes: true, | ||
compilePromise.then(function(result) { | ||
return compilePromise.then(function(result) { | ||
var desc = "Expected elm-make to return the result of the compilation"; | ||
expect(result.toString(), desc).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
it("reports errors on bad source", function (done) { | ||
it("reports errors on bad syntax", function () { | ||
var opts = { | ||
@@ -95,11 +94,28 @@ yes: true, | ||
compilePromise.catch(function(err) { | ||
var desc = "Expected elm-make to have exit code 1"; | ||
expect(err, desc).to.equal("Compiler process exited with code 1"); | ||
done(); | ||
return compilePromise.catch(function(err) { | ||
expect(err).to.be.an('error'); | ||
expect(String(err)) | ||
.to.contain("Compilation failed") | ||
.and.contain("SYNTAX PROBLEM"); | ||
}); | ||
}); | ||
it("invokes custom `emitWarning`", function (done) { | ||
it("reports type errors", function () { | ||
var opts = { | ||
yes: true, | ||
verbose: true, | ||
cwd: fixturesDir | ||
}; | ||
var compilePromise = compiler.compileToString(prependFixturesDir("TypeError.elm"), opts); | ||
return compilePromise.catch(function(err) { | ||
expect(err).to.be.an('error'); | ||
expect(String(err)) | ||
.to.contain("Compilation failed") | ||
.and.contain("TYPE MISMATCH"); | ||
}); | ||
}); | ||
it("invokes custom `emitWarning`", function () { | ||
var opts = { | ||
foo: "bar", | ||
@@ -113,8 +129,35 @@ emitWarning: chai.spy(), | ||
compilePromise.then(function(err) { | ||
return compilePromise.then(function(err) { | ||
var desc = "Expected emitWarning to have been called"; | ||
expect(opts.emitWarning, desc).to.have.been.called(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe("#compileWorker", function() { | ||
// Use a timeout of 5 minutes because Travis on Linux can be SUPER slow. | ||
this.timeout(300000); | ||
it("works with BasicWorker.elm", function (done) { | ||
var opts = { | ||
yes: true, | ||
verbose: true, | ||
cwd: fixturesDir | ||
}; | ||
var compilePromise = compiler.compileWorker( | ||
prependFixturesDir(""), | ||
prependFixturesDir("BasicWorker.elm"), | ||
"BasicWorker" | ||
); | ||
return compilePromise.then(function(app) { | ||
app.ports.report.subscribe(function(str) { | ||
expect(str).to.equal("it's alive!"); | ||
done(); | ||
}); | ||
}) | ||
.catch(function (err) { | ||
throw(err); | ||
}) | ||
}); | ||
}); |
@@ -12,5 +12,6 @@ { | ||
"dependencies": { | ||
"elm-lang/core": "3.0.0 <= v < 4.0.0" | ||
"elm-lang/core": "4.0.0 <= v < 5.0.0", | ||
"elm-lang/html": "1.0.0 <= v < 2.0.0" | ||
}, | ||
"elm-version": "0.16.0 <= v < 0.17.0" | ||
"elm-version": "0.17.0 <= v < 0.18.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24997
25
525
58
6