Skip to content

Commit 3055a20

Browse files
realitykingMike-Dax
authored andcommitted
Make use of some ES2015 features
1 parent af801e2 commit 3055a20

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

index.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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');
46

57
/**
68
* Extract the @import statements from a given less file's content
@@ -12,8 +14,8 @@ module.exports = function detective(fileContent) {
1214
if (typeof fileContent === 'undefined') { throw new Error('content not given'); }
1315
if (typeof fileContent !== 'string') { throw new Error('content is not a string'); }
1416

15-
var dependencies = [];
16-
var ast;
17+
let dependencies = [];
18+
let ast;
1719

1820
try {
1921
debug('content: ' + fileContent);
@@ -25,7 +27,7 @@ module.exports = function detective(fileContent) {
2527

2628
detective.ast = ast;
2729

28-
var walker = new Walker();
30+
const walker = new Walker();
2931

3032
walker.walk(ast, function(node) {
3133
if (!isImportStatement(node)) { return; }
@@ -40,11 +42,11 @@ function isImportStatement(node) {
4042
if (!node || node.type !== 'atrule') { return false; }
4143
if (!node.content.length || node.content[0].type !== 'atkeyword') { return false; }
4244

43-
var atKeyword = node.content[0];
45+
const atKeyword = node.content[0];
4446

4547
if (!atKeyword.content.length) { return false; }
4648

47-
var importKeyword = atKeyword.content[0];
49+
const importKeyword = atKeyword.content[0];
4850

4951
if (importKeyword.type !== 'ident' || importKeyword.content !== 'import') { return false; }
5052

test/test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
var detective = require('../');
2-
var assert = require('assert');
1+
'use strict';
2+
3+
const detective = require('../');
4+
const assert = require('assert');
35

46
describe('detective-less', function() {
57
function test(src, deps, opts) {

0 commit comments

Comments
 (0)