Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Elm 0.19 #8

Merged
merged 2 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ function findAllDependencies(file, knownDependencies, sourceDirectories, knownFi
}

// Given a source directory (containing top-level Elm modules), locate the
// elm-package.json file that includes it and get all its source directories.
// elm.json file that includes it and get all its source directories.
function getElmPackageSourceDirectories(baseDir, currentDir) {
if (typeof currentDir === "undefined") {
baseDir = path.resolve(baseDir);
currentDir = baseDir;
}

var elmPackagePath = path.join(currentDir, 'elm-package.json');
var elmPackagePath = path.join(currentDir, 'elm.json');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really elmPackagePath anymore, isn't it more like elmJsonPath?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's still the file that defines the packages on which the elm build depends.
I'm happy to make the change to elmJsonPath if this terminology seems more sensible :)

if (fs.existsSync(elmPackagePath)) {
var sourceDirectories = getSourceDirectories(elmPackagePath);
if (_.includes(sourceDirectories, baseDir)) {
Expand Down
10 changes: 5 additions & 5 deletions test/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ describe("#findAllDependencies", function() {
});
});

it("ignores an elm-package.json file that does not list the module's source directory", function() {
it("ignores an elm.json file that does not list the module's source directory", function() {
return findAllDependencies(prependFixturesDir("other-src/OtherParent.elm")).then(function(results) {
expect(results).to.deep.equal(
[ "Test/ChildA.elm" ].map(prependFixturesDir)
);
});
});

it("ignores an elm-package.json file missing the source-directories key", function() {
return findAllDependencies(prependFixturesDir("no-source-directories-elm-package-json/Main.elm")).then(function(results) {
it("ignores an elm.json file missing the source-directories key", function() {
return findAllDependencies(prependFixturesDir("no-source-directories-elm-json/Main.elm")).then(function(results) {
expect(results).to.deep.equal([]);
});
});

it("gracefully ignores malformed elm-package.json files", function() {
return findAllDependencies(prependFixturesDir("malformed-elm-package-json/Main.elm")).then(function(results) {
it("gracefully ignores malformed elm.json files", function() {
return findAllDependencies(prependFixturesDir("malformed-elm-json/Main.elm")).then(function(results) {
expect(results).to.deep.equal([]);
})
});
Expand Down
17 changes: 0 additions & 17 deletions test/fixtures/elm-package.json

This file was deleted.

25 changes: 25 additions & 0 deletions test/fixtures/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "application",
"source-directories": [
".",
"other-src"
],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/json": "1.0.0"
},
"indirect": {
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
22 changes: 22 additions & 0 deletions test/fixtures/no-source-directories-elm-json/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"type": "application",
"source-directories": [],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/json": "1.0.0"
},
"indirect": {
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}

This file was deleted.

16 changes: 0 additions & 16 deletions test/fixtures/other-src/elm-package.json

This file was deleted.

24 changes: 24 additions & 0 deletions test/fixtures/other-src/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "application",
"source-directories": [
"bad-directory-does-not-exist"
],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/json": "1.0.0"
},
"indirect": {
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}