1
- var Walker = require ( 'node-source-walk' ) ;
2
- var gonzales = require ( 'gonzales-pe' ) ;
3
- var debug = require ( 'debug' ) ( 'detective-less' ) ;
1
+ 'use strict' ;
2
+
3
+ const Walker = require ( 'node-source-walk' ) ;
4
+ const gonzales = require ( 'gonzales-pe' ) ;
5
+ const debug = require ( 'debug' ) ( 'detective-less' ) ;
4
6
5
7
/**
6
8
* Extract the @import statements from a given less file's content
@@ -12,8 +14,8 @@ module.exports = function detective(fileContent) {
12
14
if ( typeof fileContent === 'undefined' ) { throw new Error ( 'content not given' ) ; }
13
15
if ( typeof fileContent !== 'string' ) { throw new Error ( 'content is not a string' ) ; }
14
16
15
- var dependencies = [ ] ;
16
- var ast ;
17
+ let dependencies = [ ] ;
18
+ let ast ;
17
19
18
20
try {
19
21
debug ( 'content: ' + fileContent ) ;
@@ -25,7 +27,7 @@ module.exports = function detective(fileContent) {
25
27
26
28
detective . ast = ast ;
27
29
28
- var walker = new Walker ( ) ;
30
+ const walker = new Walker ( ) ;
29
31
30
32
walker . walk ( ast , function ( node ) {
31
33
if ( ! isImportStatement ( node ) ) { return ; }
@@ -40,11 +42,11 @@ function isImportStatement(node) {
40
42
if ( ! node || node . type !== 'atrule' ) { return false ; }
41
43
if ( ! node . content . length || node . content [ 0 ] . type !== 'atkeyword' ) { return false ; }
42
44
43
- var atKeyword = node . content [ 0 ] ;
45
+ const atKeyword = node . content [ 0 ] ;
44
46
45
47
if ( ! atKeyword . content . length ) { return false ; }
46
48
47
- var importKeyword = atKeyword . content [ 0 ] ;
49
+ const importKeyword = atKeyword . content [ 0 ] ;
48
50
49
51
if ( importKeyword . type !== 'ident' || importKeyword . content !== 'import' ) { return false ; }
50
52
0 commit comments