@abmaonline/less-tree 中文文档教程
@abmaonline/less-tree
Get less import vinyl file tree
最初由 LingyuCoder 创建,但是在 github 上不再可用,并进行了一些更改以使其更健壮。
Installation
$ npm install --save @abmaonline/less-tree
Usage
Create Tree
const lessTree = require('@abmaonline/less-tree');
// create less vinyl file tree
let root = lessTree('a.less');
root.children // => get tree children vinyl file object
toTreeObject
// get tree object
root.toTreeObject();
/*
{
'b.less': {
'd.less': {
'sub/f.less': {}
}
},
'c.less': {
'd.less': {
'sub/f.less': {}
}
},
'sub/e.less': {}
}
*/
toTreeString
// get tree string
root.toTreeString();
/*
├─ b.less
│ └─ d.less
│ └─ sub/f.less
├─ c.less
│ └─ d.less
│ └─ sub/f.less
└─ sub/e.less
*/
Todo
- tree walker
- …
Test
$ npm run test
$ npm run test-cov
@abmaonline/less-tree
Get less import vinyl file tree
Originally created by LingyuCoder, but no longer available on github and made some changes to make it more robust.
Installation
$ npm install --save @abmaonline/less-tree
Usage
Create Tree
const lessTree = require('@abmaonline/less-tree');
// create less vinyl file tree
let root = lessTree('a.less');
root.children // => get tree children vinyl file object
toTreeObject
// get tree object
root.toTreeObject();
/*
{
'b.less': {
'd.less': {
'sub/f.less': {}
}
},
'c.less': {
'd.less': {
'sub/f.less': {}
}
},
'sub/e.less': {}
}
*/
toTreeString
// get tree string
root.toTreeString();
/*
├─ b.less
│ └─ d.less
│ └─ sub/f.less
├─ c.less
│ └─ d.less
│ └─ sub/f.less
└─ sub/e.less
*/
Todo
- tree walker
- …
Test
$ npm run test
$ npm run test-cov