diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index b02850a1..f8f06e91 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -111,59 +111,13 @@ class Pipeline { return fileCb("couldn't find file: " + file.filename); } let fileContent = fs.readFileSync('./.embark/' + file.filename).toString(); - - let pipelinePlugins = self.plugins.getPluginsFor('pipeline'); - - if (pipelinePlugins.length > 0) { - async.eachSeries(pipelinePlugins, function(plugin, pluginCB) { - if (file.options && file.options.skipPipeline) { - return pluginCB(); - } - - fileContent = plugin.runPipeline({targetFile: file.filename, source: fileContent}); - file.modified = true; - pluginCB(); - }, - function (err) { - if (err) { - self.logger.error(err.message); - } - return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true}); - }); - } else { - return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true}); - } + self.runPlugins(file, fileContent, fileCb); }); - } else { - - let pipelinePlugins = self.plugins.getPluginsFor('pipeline'); - if (pipelinePlugins.length > 0) { - file.content(function(fileContent) { - async.eachSeries(pipelinePlugins, function(plugin, pluginCB) { - if (file.options && file.options.skipPipeline) { - return pluginCB(); - } - - fileContent = plugin.runPipeline({targetFile: file.filename, source: fileContent}); - file.modified = true; - pluginCB(); - }, - function (err) { - if (err) { - self.logger.error(err.message); - } - return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true}); - }); - }); - } else { - file.content(function(fileContent) { - return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true}); - }); - } - + file.content(function(fileContent) { + self.runPlugins(file, fileContent, fileCb); + }); } - }, function (err, contentFiles) { if (err) { @@ -208,6 +162,31 @@ class Pipeline { }); } + runPlugins(file, fileContent, fileCb) { + const self = this; + let pipelinePlugins = self.plugins.getPluginsFor('pipeline'); + if (pipelinePlugins.length <= 0) { + return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true}); + } + async.eachSeries(pipelinePlugins, + function(plugin, pluginCB) { + if (file.options && file.options.skipPipeline) { + return pluginCB(); + } + + fileContent = plugin.runPipeline({targetFile: file.filename, source: fileContent}); + file.modified = true; + pluginCB(); + }, + function (err) { + if (err) { + self.logger.error(err.message); + } + return fileCb(null, {content: fileContent, filename: file.filename, path: file.path, basedir: file.basedir, modified: true}); + } + ); + } + webpackRun(filename, options, includeModules, importsList, detectErrors, callback) { let defaultOptions = { entry: utils.joinPath(fs.dappPath(), filename),