Skip to content

Instantly share code, notes, and snippets.

@thybzi
Created April 1, 2017 23:05
Show Gist options
  • Save thybzi/41ba2209ba8ba1acfaaac259190c4456 to your computer and use it in GitHub Desktop.
Save thybzi/41ba2209ba8ba1acfaaac259190c4456 to your computer and use it in GitHub Desktop.
LESS import tree; using https://github.com/es128/progeny
// usage: node less-import-tree.js myfile.less
// change dirPath to whatever you need
var args = process.argv.slice(2);
var path = require('path');
var progeny = require('progeny');
var dirPath = 'resources/less';
var fileName = args[0];
var filePath = path.join(dirPath, fileName);
progeny({
extension: 'less',
regexp: /^\s*@import\s*(?:\(\w+\)\s*)?['"]([^'"]+)['"]/,
debug: true
})(filePath, function(error, result) {
// console.log(error || result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment