🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

dir-parser

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-parser - npm Package Compare versions

Comparing version
2.1.2
to
2.1.3
+2
-2
package.json
{
"name": "dir-parser",
"version": "2.1.2",
"version": "2.1.3",
"description": "Parse a directory and generate it's structure tree.",

@@ -47,4 +47,4 @@ "main": "index.js",

"commander": "^2.20.3",
"funclib": "^4.1.3"
"funclib": "^6.0.1"
}
}

@@ -40,4 +40,3 @@ <h1 align="center">😎 文件夹解析器[Dir Parser v2] 😎</h1>

- [2.3.15 配置文件-config](#2315-配置文件-config)
- [2.4 文件名称包含空格](#24-文件名称包含空格)
- [2.5 多个命令混合使用](#25-多个命令混合使用)
- [2.4 多个命令混合使用](#24-多个命令混合使用)
- [三、在Js代码中使用](#三在Js代码中使用)

@@ -158,2 +157,19 @@ - [3.1 方法接口](#31-方法接口)

```
文件或文件名称中包含空格:<br>
`$ touch 'white space.txt'`<br>
`$ parser -e '[".git", "node_modules", "public", "white space.txt"]'`
```
myapp ( directories: 3, Files: 8 )
├─ bin
│ └─ www
├─ routes
│ ├─ index.js
│ └─ users.js
├─ views
│ ├─ error.jade
│ ├─ index.jade
│ └─ layout.jade
├─ app.js
└─ package.json
```

@@ -402,27 +418,3 @@ #### 2.3.2 忽略项-ignores

### 2.4 文件名称包含空格
`touch 'white space.txt'`<br>
`parser -e '["node_modules", "white space.txt"]'`
```
myapp ( directories: 7, Files: 10 )
├─ bin
│ └─ www
├─ public
│ ├─ images/
│ ├─ javascripts/
│ └─ stylesheets
│ └─ style.css
├─ routes
│ ├─ index.js
│ └─ users.js
├─ views
│ ├─ error.jade
│ ├─ index.jade
│ └─ layout.jade
├─ app.js
├─ package.json
└─ parser.conf.json
```
### 2.5 多个命令混合使用
### 2.4 多个命令混合使用
`parser -e node_modules,bin -I views -d 2 -Nr`

@@ -429,0 +421,0 @@ ```

+19
-27

@@ -40,4 +40,3 @@ <h1 align="center">😎 Dir Parser v2 😎</h1>

- [2.3.15 config](#2315-config)
- [2.4 Name has white space](#24-name-has-white-space)
- [2.5 Use multiple commands together](#25-use-multiple-commands-together)
- [2.4 Use multiple commands together](#24-use-multiple-commands-together)
- [3. In JavaScript](#3-in-javascript)

@@ -158,2 +157,19 @@ - [3.1 Interface](#31-interface)

```
Name has white space:<br>
`$ touch 'white space.txt'`<br>
`$ parser -e '[".git", "node_modules", "public", "white space.txt"]'`
```
myapp ( directories: 3, Files: 8 )
├─ bin
│ └─ www
├─ routes
│ ├─ index.js
│ └─ users.js
├─ views
│ ├─ error.jade
│ ├─ index.jade
│ └─ layout.jade
├─ app.js
└─ package.json
```

@@ -402,27 +418,3 @@ #### 2.3.2 ignores

### 2.4 Name has white space
`touch 'white space.txt'`<br>
`parser -e '["node_modules", "white space.txt"]'`
```
myapp ( directories: 7, Files: 10 )
├─ bin
│ └─ www
├─ public
│ ├─ images/
│ ├─ javascripts/
│ └─ stylesheets
│ └─ style.css
├─ routes
│ ├─ index.js
│ └─ users.js
├─ views
│ ├─ error.jade
│ ├─ index.jade
│ └─ layout.jade
├─ app.js
├─ package.json
└─ parser.conf.json
```
### 2.5 Use multiple commands together
### 2.4 Use multiple commands together
`parser -e node_modules,bin -I views -d 2 -Nr`

@@ -429,0 +421,0 @@ ```

const fs = require('fs');
const path = require('path');
const fn = require('funclib');
const { drop, typeVal, typeOf, get, isNum } = require('funclib/lib');
const { DirInfo, FileInfo, calcSizekb } = require('./base');

@@ -31,3 +31,3 @@

function fmtMatchs(exs) {
return fn.drop(exs.map(ex => fn.typeVal(ex, 'str')));
return drop(exs.map(ex => typeVal(ex, 'str')));
}

@@ -40,3 +40,3 @@

function fmtPaths(pts) {
return fn.drop(pts.map(ex => fn.typeVal(ex, 'str') ? path.resolve(ex) : ''));
return drop(pts.map(ex => typeVal(ex, 'str') ? path.resolve(ex) : ''));
}

@@ -49,6 +49,6 @@

function fmtPatterns(ptns) {
return fn.drop(ptns.map(ptn => {
if (fn.typeOf(ptn, 'ptn')) {
return drop(ptns.map(ptn => {
if (typeOf(ptn, 'ptn')) {
return ptn;
} else if (fn.typeVal(ptn, 'str')) {
} else if (typeVal(ptn, 'str')) {
return new RegExp(ptn.replace(/(\*?)\.([\w\d]*\$+)$/, () => `${RegExp.$1 && '\.*' || ''}\.${RegExp.$2}`));

@@ -71,21 +71,21 @@ } else {

let depth = fn.get(options, 'depth', 'num');
if (!fn.isNum(depth)) depth = 0;
let depth = get(options, 'depth', 'num');
if (!isNum(depth)) depth = 0;
const isReverse = fn.get(options, 'reverse', 'bol');
const isFileFirst = fn.get(options, 'fileFirst', 'bol');
const isFileOnly = fn.get(options, 'fileOnly', 'bol');
const isDirOnly = isFileOnly ? false : fn.get(options, 'dirOnly', 'bol');
const isHideDirInfo = !fn.get(options, 'dirInfo', 'bol');
const isGetFiles = fn.get(options, 'getFiles', 'bol');
const isGetChildren = fn.get(options, 'getChildren', 'bol');
const isGetDirTree = fn.typeOf(options.dirTree, 'bol') ? options.dirTree : true;
const lineType = fn.get(options, 'lineType', 'str') || 'solid';
const excludes = fmtMatchs(fn.get(options, 'excludes', 'arr') || []);
const excPaths = fmtPaths(fn.get(options, 'excPaths', 'arr') || []);
const excPatterns = fmtPatterns(fn.get(options, 'excPatterns', 'arr') || []);
const ignores = fmtMatchs(fn.get(options, 'ignores', 'arr') || []);
const includes = fmtMatchs(fn.get(options, 'includes', 'arr') || []);
const paths = fmtPaths(fn.get(options, 'paths', 'arr') || []);
const patterns = fmtPatterns(fn.get(options, 'patterns', 'arr') || []);
const isReverse = get(options, 'reverse', 'bol');
const isFileFirst = get(options, 'fileFirst', 'bol');
const isFileOnly = get(options, 'fileOnly', 'bol');
const isDirOnly = isFileOnly ? false : get(options, 'dirOnly', 'bol');
const isHideDirInfo = !get(options, 'dirInfo', 'bol');
const isGetFiles = get(options, 'getFiles', 'bol');
const isGetChildren = get(options, 'getChildren', 'bol');
const isGetDirTree = typeOf(options.dirTree, 'bol') ? options.dirTree : true;
const lineType = get(options, 'lineType', 'str') || 'solid';
const excludes = fmtMatchs(get(options, 'excludes', 'arr') || []);
const excPaths = fmtPaths(get(options, 'excPaths', 'arr') || []);
const excPatterns = fmtPatterns(get(options, 'excPatterns', 'arr') || []);
const ignores = fmtMatchs(get(options, 'ignores', 'arr') || []);
const includes = fmtMatchs(get(options, 'includes', 'arr') || []);
const paths = fmtPaths(get(options, 'paths', 'arr') || []);
const patterns = fmtPatterns(get(options, 'patterns', 'arr') || []);

@@ -92,0 +92,0 @@ let dirTree = '';