Skip to content

Commit

Permalink
Fix syntax error to pass the test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesjieye committed Mar 23, 2018
1 parent c85c08e commit 78eecac
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions index.js
@@ -1,14 +1,12 @@
'use strict';
var assert = require('assert');

function HtmlWebpackExcludeAssetsPlugin(options) {
function HtmlWebpackExcludeAssetsPlugin (options) {
assert.equal(options, undefined, 'The HtmlWebpackExcludeAssetsPlugin does not accept any options');
this.PluginName = 'HtmlWebpackExcludeAssetsPlugin';
}

HtmlWebpackExcludeAssetsPlugin.prototype.apply = function (compiler) {
var self = this;

if ('hooks' in compiler) {
// v4 approach:
compiler.hooks.compilation.tap(this.PluginName, this.applyCompilation.bind(this));
Expand All @@ -19,19 +17,19 @@ HtmlWebpackExcludeAssetsPlugin.prototype.apply = function (compiler) {
}
};

HtmlWebpackExcludeAssetsPlugin.prototype.applyCompilation = function applyCompilation(compilation) {
HtmlWebpackExcludeAssetsPlugin.prototype.applyCompilation = function applyCompilation (compilation) {
var self = this;
if ('hooks' in compilation) {
// If our target hook is not present, throw a descriptive error
if(!compilation.hooks.htmlWebpackPluginAlterAssetTags) {
if (!compilation.hooks.htmlWebpackPluginAlterAssetTags) {
throw new Error('The expected HtmlWebpackPlugin hook was not found! Ensure HtmlWebpackPlugin is installed and' +
' was initialized before this plugin.');
}
compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync(this.PluginName, registerCb);
} else {
compilation.plugin('html-webpack-plugin-alter-asset-tags', registerCb);
}
function registerCb(htmlPluginData, callback) {
function registerCb (htmlPluginData, callback) {
var excludeAssets = htmlPluginData.plugin.options.excludeAssets;
// Skip if the plugin configuration didn't set `excludeAssets`
if (!excludeAssets) {
Expand All @@ -58,7 +56,7 @@ HtmlWebpackExcludeAssetsPlugin.prototype.applyCompilation = function applyCompil
return Promise.resolve(result);
}
}
}
};

HtmlWebpackExcludeAssetsPlugin.prototype.isExcluded = function (excludePatterns, assetPath) {
return excludePatterns.filter(function (excludePattern) {
Expand Down

0 comments on commit 78eecac

Please sign in to comment.