Socket
Socket
Sign inDemoInstall

node-elm-compiler

Package Overview
Dependencies
21
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.3.0

10

examples/compileHelloWorld.js
var compile = require("../index.js").compile;
var compileToString = require("../index.js").compileToString;

@@ -8,1 +9,10 @@ compile(["./HelloWorld.elm"], {

});
compileToString(["./HelloWorld.elm"], { yes: true }).then(function(data){
console.log("Text", data.toString());
});
compileToString(["./HelloWorld.elm"], { yes: true, output: "index.html" }).then(function(data){
console.log("Text", data.toString());
});

@@ -8,2 +8,3 @@ 'use strict';

var path = require("path");
var temp = require("temp");

@@ -23,2 +24,3 @@ var defaultOptions = {

function compile(sources, options) {

@@ -144,2 +146,32 @@ if (typeof sources === "string") {

// write compiled Elm to a string output
// returns a Promise which will contain a Buffer of the text
// If you want html instead of js, use options object to set
// output to a html file instead
// creates a temp file and deletes it after reading
function compileToString(sources, options){
if (typeof options.output === "undefined"){
options.output = '.js';
}
return new Promise(function(resolve, reject){
temp.open({ suffix: options.output }, function(err, info){
if (err){
return reject(err);
}
options.output = info.path;
compile(sources, options)
.on("close", function(exitCode){
fs.readFile(info.path, function(err, data){
temp.cleanupSync();
return err ? reject(err) : resolve(data);
});
});
});
});
}
function checkIsFile(file) {

@@ -197,3 +229,4 @@ return new Promise(function(resolve, reject) {

compile: compile,
compileToString: compileToString,
findAllDependencies: findAllDependencies
};

7

package.json
{
"name": "node-elm-compiler",
"version": "2.2.0",
"version": "2.3.0",
"description": "A Node.js interface to the Elm compiler binaries. Supports Elm versions 0.15 - 0.16.",
"main": "index.js",
"scripts": {
"test": "cd test/fixtures && elm-package install --yes && cd ../.. && mocha test/*.js"
"test": "mocha test/*.js"
},

@@ -33,4 +33,5 @@ "repository": {

"chai": "3.4.1",
"mocha": "2.3.4"
"mocha": "2.3.4",
"temp": "^0.8.3"
}
}

@@ -17,2 +17,10 @@ # 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)

## 2.3.0
Added #compileToString
## 2.2.0
Added `cwd` to `options` and fixed a bug where Windows couldn't find `elm-make`.
## 2.1.0

@@ -19,0 +27,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc