Skip to content

Commit 3b8c95d

Browse files
committed
abstract out ext and config setup into methods
1 parent 794f0fb commit 3b8c95d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ class HTMLValidatePlugin {
77
{
88
// default values
99
path: 'src/**/*',
10-
extensions: ['html'],
11-
config: false,
10+
extensions: 'html',
11+
config: '.htmlvalidate',
1212
global: false,
1313
},
1414
({
@@ -22,6 +22,14 @@ class HTMLValidatePlugin {
2222
);
2323
}
2424

25+
getExtensions() {
26+
return this.extensions === 'html' ? this.extensions : this.convertExtensionArrayToRegex();
27+
}
28+
29+
getConfig() {
30+
return '--config ' + this.config + '.json';
31+
}
32+
2533
convertExtensionArrayToRegex() {
2634
// replace array as curly braced string for replacing commas and spaces
2735
let processedExtension = `"{${this.extensions}}"`.replace(/\"/g, '').replace(/\ /g, '');
@@ -46,9 +54,7 @@ class HTMLValidatePlugin {
4654
// initiate script when webpack compilation is completed
4755
compiler.hooks.done.tap('HTMLValidatePlugin', () => {
4856
// set up cli payload
49-
const userParams = `${this.path}.${this.convertExtensionArrayToRegex()} ${
50-
this.config ? '--config ' + this.config + '.json' : this.config
51-
}`;
57+
const userParams = `${this.path}.${this.getExtensions()} ${this.getConfig()}`;
5258
const spawnParams = {
5359
shell: true,
5460
/*inherit color output */ stdio: 'inherit',

0 commit comments

Comments
 (0)