Socket
Socket
Sign inDemoInstall

node-elm-compiler

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-elm-compiler - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

test/fixtures/Nested/Child.elm

42

index.js

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

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

@@ -72,2 +73,28 @@ var defaultOptions = {

function getBaseDir(file) {
return firstline(file).then(function(line) {
return new Promise(function(resolve, reject) {
var matches = line.match(/^module\s+([^\s]+)/);
if (matches) {
// e.g. Css.Declarations
var moduleName = matches[1];
// e.g. Css/Declarations
var dependencyLogicalName = moduleName.replace(/\./g, "/");
// e.g. ../..
var backedOut = dependencyLogicalName.replace(/[^/]+/g, "..");
// e.g. /..
var trimmedBackedOut = backedOut.replace(/^../, "");
return resolve(path.normalize(path.dirname(file) + trimmedBackedOut));
}
return reject(file + " is not a syntactically valid Elm module. Try running elm-make on it manually to figure out what the problem is.");
});
});
}
// Returns a Promise that returns a flat list of all the Elm files the given

@@ -80,8 +107,13 @@ // Elm file depends on, based on the modules it loads via `import`.

if (!baseDir) {
baseDir = path.dirname(file);
if (baseDir) {
return findAllDependenciesHelp(file, knownDependencies, baseDir);
} else {
return getBaseDir(file).then(function(newBaseDir) {
return findAllDependenciesHelp(file, knownDependencies, newBaseDir);
});
}
}
function findAllDependenciesHelp(file, knownDependencies, baseDir) {
return new Promise(function(resolve, reject) {
fs.readFile(file, {encoding: "utf8"}, function(err, lines) {

@@ -140,3 +172,3 @@ if (err) {

return path.extname(dependency) === ".elm" ?
findAllDependencies(dependency, newDependencies, baseDir) : null;
findAllDependenciesHelp(dependency, newDependencies, baseDir) : null;
}));

@@ -187,3 +219,3 @@

} else if (options.verbose) {
console.log(output)
console.log(output);
}

@@ -190,0 +222,0 @@

4

package.json
{
"name": "node-elm-compiler",
"version": "4.1.0",
"version": "4.1.1",
"description": "A Node.js interface to the Elm compiler binaries. Supports Elm version 0.17",

@@ -29,5 +29,5 @@ "main": "index.js",

"cross-spawn": "4.0.0",
"firstline": "1.2.0",
"lodash": "4.14.2",
"temp": "^0.8.3"
},

@@ -34,0 +34,0 @@ "devDependencies": {

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

## 4.1.1
Fix bug in dependency searches beginning with a non-root `Main` module.
## 4.1.0

@@ -19,0 +23,0 @@

@@ -27,2 +27,11 @@ var expect = require("chai").expect;

});
it("works for a non-root file with nested dependencies", function () {
return compiler.findAllDependencies(prependFixturesDir(
path.join("Nested", "Parent", "Test.elm"))).then(function(results) {
expect(results).to.deep.equal(
[ "Test/ChildA.elm", "Nested/Child.elm", "Nested/Test/Child.elm", "Test/Sample/NestedChild.elm", "Test/ChildB.elm", "Native/Child.js" ].map(prependFixturesDir)
);
});
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc