1
1
'use strict' ;
2
2
3
- const { assign, identity, negate, camelCase : camelCaseFunc , mapKeys } = require ( 'lodash' ) ;
3
+ const { assign, identity, negate} = require ( 'lodash' ) ;
4
4
const { dirname, relative, resolve} = require ( 'path' ) ;
5
5
const { readFileSync} = require ( 'fs' ) ;
6
6
const { transformTokens} = require ( './transformTokens' ) ;
@@ -48,16 +48,13 @@ module.exports = function setupHook({
48
48
: process . env . NODE_ENV === 'development' ;
49
49
50
50
let scopedName ;
51
- if ( generateScopedName ) {
51
+ if ( generateScopedName )
52
52
scopedName = typeof generateScopedName !== 'function'
53
53
? genericNames ( generateScopedName , { context, hashPrefix} ) // for example '[name]__[local]___[hash:base64:5]'
54
54
: generateScopedName ;
55
- } else {
55
+ else
56
56
// small fallback
57
- scopedName = ( local , filename ) => {
58
- return Scope . generateScopedName ( local , relative ( context , filename ) ) ;
59
- } ;
60
- }
57
+ scopedName = ( local , filename ) => Scope . generateScopedName ( local , relative ( context , filename ) ) ;
61
58
62
59
const plugins = ( use || [
63
60
...prepend ,
@@ -83,7 +80,7 @@ module.exports = function setupHook({
83
80
*/
84
81
function fetch ( _to , from ) {
85
82
// getting absolute path to the processing file
86
- const filename = / [ ^ \\ / ? % * : | " < > \ .] / i. test ( _to [ 0 ] )
83
+ const filename = / [ ^ \\ / ? % * : | " < > . ] / i. test ( _to [ 0 ] )
87
84
? require . resolve ( _to )
88
85
: resolve ( dirname ( from ) , _to ) ;
89
86
@@ -104,23 +101,21 @@ module.exports = function setupHook({
104
101
105
102
tokens = lazyResult . root . tokens ;
106
103
107
- if ( ! debugMode ) {
104
+ if ( ! debugMode )
108
105
// updating cache
109
106
tokensByFile [ filename ] = tokens ;
110
- } else {
107
+ else
111
108
// clearing cache in development mode
112
109
delete require . cache [ filename ] ;
113
- }
114
110
115
- if ( processCss ) {
111
+ if ( processCss )
116
112
processCss ( lazyResult . css , filename ) ;
117
- }
118
113
119
114
debugFetch ( `${ filename } → fs` ) ;
120
115
debugFetch ( tokens ) ;
121
116
122
117
return tokens ;
123
- } ;
118
+ }
124
119
125
120
const exts = toArray ( extensions ) ;
126
121
const isException = buildExceptionChecker ( ignore ) ;
@@ -149,13 +144,11 @@ function toArray(option) {
149
144
* @return {function }
150
145
*/
151
146
function buildExceptionChecker ( ignore ) {
152
- if ( ignore instanceof RegExp ) {
147
+ if ( ignore instanceof RegExp )
153
148
return filepath => ignore . test ( filepath ) ;
154
- }
155
149
156
- if ( typeof ignore === 'string' ) {
150
+ if ( typeof ignore === 'string' )
157
151
return filepath => globToRegex ( ignore ) . test ( filepath ) ;
158
- }
159
152
160
153
return ignore || negate ( identity ) ;
161
154
}
0 commit comments