diff --git a/lib/config.js b/lib/config.js index bc3236a21..f56c99036 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,5 +1,4 @@ var fs = require('fs'); -var grunt = require('grunt'); var merge = require('merge'); var Plugins = require('./plugins.js'); var utils = require('./utils.js'); @@ -149,7 +148,7 @@ Config.prototype.loadChainTrackerFile = function() { Config.prototype.loadFiles = function(files) { var self = this; - var originalFiles = grunt.file.expand({nonull: true}, files); + var originalFiles = utils.filesMatchinPattern(files); var readFiles = []; // get embark.js object first @@ -187,7 +186,7 @@ Config.prototype.loadFiles = function(files) { } filesFromPlugins.filter(function(file) { - if (grunt.file.isMatch(files, file.intendedPath)) { + if (utils.fileMatchesPattern(files, file.intendedPath)) { readFiles.push(file); } }); diff --git a/lib/plugin.js b/lib/plugin.js index a0e7bab6a..574193114 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,5 +1,4 @@ /*jshint esversion: 6, loopfunc: true */ -var grunt = require('grunt'); var fs = require('fs'); var utils = require('./utils.js'); @@ -146,7 +145,7 @@ Plugin.prototype.runFilePipeline = function() { Plugin.prototype.runPipeline = function(args) { // TODO: should iterate the pipelines var pipeline = this.pipeline[0]; - var shouldRunPipeline = grunt.file.isMatch(pipeline.matcthingFiles, args.targetFile); + var shouldRunPipeline = utils.fileMatchesPattern(pipeline.matcthingFiles, args.targetFile); if (shouldRunPipeline) { return pipeline.cb.call(this, args); } else { diff --git a/lib/utils.js b/lib/utils.js index 2228fb395..e5143661a 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,9 +1,18 @@ var path = require('path'); +var grunt = require('grunt'); function joinPath() { return path.join.apply(path.join, arguments); } +function filesMatchinPattern(files) { + return grunt.file.expand({nonull: true}, files); +} + +function fileMatchesPattern(patterns, intendedPath) { + return grunt.file.isMatch(patterns, intendedPath); +} + module.exports = { joinPath: joinPath };