Skip to content

Commit

Permalink
Update for Elm 0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
xtian committed May 10, 2018
1 parent 7d1c6d9 commit f116fec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var alreadyCompiledFiles = [];
var defaultOptions = {
cache: false,
forceWatch: false,
yes: true
};

var getFiles = function(options) {
Expand All @@ -38,9 +37,7 @@ var getOptions = function() {
? this.options.elm || {}
: this.query.elm || {};
var loaderOptions = loaderUtils.getOptions(this) || {};
return Object.assign({
emitWarning: this.emitWarning
}, defaultOptions, globalOptions, loaderOptions);
return Object.assign({}, defaultOptions, globalOptions, loaderOptions);
};

var _addDependencies = function(dependency) {
Expand Down Expand Up @@ -76,10 +73,10 @@ var isInWatchMode = function(){
return hasWebpackDevServer || hasWatchArg || hasStdinArg;
};

/* Takes a working dir, tries to read elm-package.json, then grabs all the modules from in there
/* Takes a working dir, tries to read elm.json, then grabs all the modules from in there
*/
var filesToWatch = function(cwd){
var readFile = fs.readFileSync(path.join(cwd, "elm-package.json"), 'utf8');
var readFile = fs.readFileSync(path.join(cwd, "elm.json"), 'utf8');
var elmPackage = JSON.parse(readFile);

var paths = elmPackage["source-directories"].map(function(dir){
Expand Down Expand Up @@ -127,11 +124,11 @@ module.exports = function() {
if (options.forceWatch || isInWatchMode()){
// we can do a glob to track deps we care about if cwd is set
if (typeof options.cwd !== "undefined" && options.cwd !== null){
// watch elm-package.json
var elmPackage = path.join(options.cwd, "elm-package.json");
// watch elm.json
var elmPackage = path.join(options.cwd, "elm.json");
addDependencies(elmPackage);
var dirs = filesToWatch(options.cwd);
// watch all the dirs in elm-package.json
// watch all the dirs in elm.json
addDirDependency.bind(this)(dirs);
}

Expand Down Expand Up @@ -165,7 +162,7 @@ module.exports = function() {
clearInterval(intervalId);

// If we are running in watch mode, and we have previously compiled
// the current file, then let the user know that elm-make is running
// the current file, then let the user know that `elm make` is running
// and can be slow
if (alreadyCompiledFiles.indexOf(resourcePath) > -1){
console.log('Started compiling Elm..');
Expand Down Expand Up @@ -214,4 +211,4 @@ function remove(condemned, items) {
return items.filter(function(item) {
return item !== condemned;
});
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"elm": "^0.18.0",
"glob": "^7.1.1",
"loader-utils": "^1.0.2",
"node-elm-compiler": "^4.5.0",
"node-elm-compiler": "^5.0.0-alpha1",
"yargs": "^6.5.0"
},
"devDependencies": {
Expand Down

0 comments on commit f116fec

Please sign in to comment.