@@ -10,29 +10,21 @@ var OPTIONAL_COMMA = ',?';
10
10
11
11
// one line string with or without trailing comma
12
12
function makeStringRegex ( attr ) {
13
- return makeRegex (
14
- WHITESPACE_BEFORE + attr + ': \'.*\'' + OPTIONAL_COMMA
15
- ) ;
13
+ return makeRegex ( WHITESPACE_BEFORE + attr + ": '.*'" + OPTIONAL_COMMA ) ;
16
14
}
17
15
18
16
// joined array of strings with or without trailing comma
19
17
function makeJoinedArrayRegex ( attr ) {
20
- return makeRegex (
21
- WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + OPTIONAL_COMMA
22
- ) ;
18
+ return makeRegex ( WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + OPTIONAL_COMMA ) ;
23
19
}
24
20
25
21
// array with or without trailing comma
26
22
function makeArrayRegex ( attr ) {
27
- return makeRegex (
28
- WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + OPTIONAL_COMMA
29
- ) ;
23
+ return makeRegex ( WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + OPTIONAL_COMMA ) ;
30
24
}
31
25
32
26
function makeRegex ( regexStr ) {
33
- return (
34
- new RegExp ( regexStr , 'g' )
35
- ) ;
27
+ return new RegExp ( regexStr , 'g' ) ;
36
28
}
37
29
38
30
const allRegexes = [
@@ -44,15 +36,18 @@ const allRegexes = [
44
36
makeStringRegex ( 'hrName' )
45
37
] ;
46
38
47
- var esbuildPluginStripMeta = {
39
+ const esbuildPluginStripMeta = {
48
40
name : 'strip-meta-attributes' ,
49
41
setup ( build ) {
50
42
const loader = 'js' ;
51
- build . onLoad ( { filter : / \. j s $ / } , async file => ( {
52
- contents : await fs . promises . readFile ( file . path , 'utf-8' ) . then ( c => {
53
- allRegexes . forEach ( r => { c = c . replace ( r , '' ) ; } ) ;
43
+ build . onLoad ( { filter : / \. j s $ / } , async ( file ) => ( {
44
+ contents : await fs . promises . readFile ( file . path , 'utf-8' ) . then ( ( c ) => {
45
+ allRegexes . forEach ( ( r ) => {
46
+ c = c . replace ( r , '' ) ;
47
+ } ) ;
54
48
return c ;
55
- } ) , loader
49
+ } ) ,
50
+ loader
56
51
} ) ) ;
57
52
}
58
53
} ;
0 commit comments