Skip to content

Commit

Permalink
Make use of some ES2015 features
Browse files Browse the repository at this point in the history
  • Loading branch information
realityking authored and Mike-Dax committed Sep 11, 2018
1 parent af801e2 commit 3055a20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 10 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var Walker = require('node-source-walk');
var gonzales = require('gonzales-pe');
var debug = require('debug')('detective-less');
'use strict';

const Walker = require('node-source-walk');
const gonzales = require('gonzales-pe');
const debug = require('debug')('detective-less');

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

var dependencies = [];
var ast;
let dependencies = [];
let ast;

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

detective.ast = ast;

var walker = new Walker();
const walker = new Walker();

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

var atKeyword = node.content[0];
const atKeyword = node.content[0];

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

var importKeyword = atKeyword.content[0];
const importKeyword = atKeyword.content[0];

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

Expand Down
6 changes: 4 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var detective = require('../');
var assert = require('assert');
'use strict';

const detective = require('../');
const assert = require('assert');

describe('detective-less', function() {
function test(src, deps, opts) {
Expand Down

0 comments on commit 3055a20

Please sign in to comment.