readify 8.0.1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +23 -0
- package/README.md +13 -10
- package/lib/readdir.js +14 -5
- package/lib/readify.js +6 -7
- package/package.json +11 -12
package/ChangeLog
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
2024.03.29, v10.0.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 2b6413c readify: drop support of node < 18
|
|
5
|
+
- ff9b38a readify: eslint-plugin-n v16.6.2
|
|
6
|
+
- 300ac78 readify: eslint-plugin-putout v22.5.0
|
|
7
|
+
- 2de9bc7 readify: madrun v10.0.1
|
|
8
|
+
- 53810f6 readify: supertape v10.5.0
|
|
9
|
+
- 943f96a readify: putout v35.7.6
|
|
10
|
+
- f26b1cf readify: nodemon v3.1.0
|
|
11
|
+
- 3e6e321 readify: eslint v8.57.0
|
|
12
|
+
- d92788a readify: c8 v9.1.0
|
|
13
|
+
|
|
14
|
+
2021.03.01, v9.0.0
|
|
15
|
+
|
|
16
|
+
feature:
|
|
17
|
+
- feature(readify) add support of archives
|
|
18
|
+
- feature(package) eslint-plugin-putout v7.2.1
|
|
19
|
+
- feature(package) putout v15.4.3
|
|
20
|
+
- feature(package) supertape v5.0.0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
1
24
|
2021.01.20, v8.0.1
|
|
2
25
|
|
|
3
26
|
feature:
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# Readify [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![
|
|
1
|
+
# Readify [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
|
|
2
2
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/readify.svg?style=flat
|
|
4
|
-
[
|
|
5
|
-
[
|
|
4
|
+
[BuildStatusURL]: https://github.com/coderaiser/readify/actions?query=workflow%3A%22Node+CI%22 "Build Status"
|
|
5
|
+
[BuildStatusIMGURL]: https://github.com/coderaiser/readify/workflows/Node%20CI/badge.svg
|
|
6
6
|
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
|
|
7
7
|
[NPMURL]: https://npmjs.org/package/readify "npm"
|
|
8
|
-
[BuildStatusURL]: https://travis-ci.org/coderaiser/readify "Build Status"
|
|
9
|
-
[DependencyStatusURL]: https://david-dm.org/coderaiser/readify "Dependency Status"
|
|
10
8
|
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
|
|
9
|
+
[CoverageURL]: https://coveralls.io/github/coderaiser/readify?branch=master
|
|
10
|
+
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/readify/badge.svg?branch=master&service=github
|
|
11
11
|
|
|
12
12
|
Read directory content with file attributes: size, date, owner, mode and type.
|
|
13
13
|
|
|
@@ -50,7 +50,9 @@ console.log(data);
|
|
|
50
50
|
}],
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
readify('/', {
|
|
53
|
+
readify('/', {
|
|
54
|
+
type: 'raw',
|
|
55
|
+
}).then(console.log);
|
|
54
56
|
// output
|
|
55
57
|
({
|
|
56
58
|
path: '/',
|
|
@@ -64,7 +66,11 @@ readify('/', {type: 'raw'}).then(console.log);
|
|
|
64
66
|
}],
|
|
65
67
|
});
|
|
66
68
|
|
|
67
|
-
readify('/', {
|
|
69
|
+
readify('/', {
|
|
70
|
+
type: 'raw',
|
|
71
|
+
sort: 'size',
|
|
72
|
+
order: 'desc',
|
|
73
|
+
}).then(console.log);
|
|
68
74
|
// output
|
|
69
75
|
({
|
|
70
76
|
path: '/',
|
|
@@ -82,6 +88,3 @@ readify('/', {type: 'raw', sort: 'size', order: 'desc'}).then(console.log);
|
|
|
82
88
|
## License
|
|
83
89
|
|
|
84
90
|
MIT
|
|
85
|
-
|
|
86
|
-
[CoverageURL]: https://coveralls.io/github/coderaiser/readify?branch=master
|
|
87
|
-
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/readify/badge.svg?branch=master&service=github
|
package/lib/readdir.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {join} = require('path');
|
|
3
|
+
const {join, extname} = require('path');
|
|
4
4
|
const {readdir} = require('fs/promises');
|
|
5
5
|
|
|
6
6
|
const tryToCatch = require('try-to-catch');
|
|
@@ -41,26 +41,35 @@ function empty(name) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function parseStat(stat) {
|
|
44
|
+
const {name} = stat;
|
|
44
45
|
const isDir = stat.isDirectory();
|
|
45
46
|
const isLink = stat.isSymbolicLink();
|
|
46
47
|
|
|
47
48
|
return {
|
|
48
|
-
name
|
|
49
|
+
name,
|
|
49
50
|
size: stat.size,
|
|
50
51
|
date: stat.mtime,
|
|
51
52
|
owner: stat.uid,
|
|
52
53
|
mode: stat.mode,
|
|
53
54
|
type: getType({
|
|
55
|
+
name,
|
|
54
56
|
isDir,
|
|
55
57
|
isLink,
|
|
56
58
|
}),
|
|
57
59
|
};
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
function getType({isDir, isLink}) {
|
|
62
|
+
function getType({name, isDir, isLink}) {
|
|
63
|
+
let type;
|
|
64
|
+
|
|
65
|
+
if (isDir)
|
|
66
|
+
type = 'directory';
|
|
67
|
+
else if (extname(name) === '.zip')
|
|
68
|
+
type = 'archive';
|
|
69
|
+
else
|
|
70
|
+
type = 'file';
|
|
71
|
+
|
|
61
72
|
const link = isLink ? '-link' : '';
|
|
62
|
-
const type = isDir ? 'directory' : 'file';
|
|
63
73
|
|
|
64
74
|
return `${type}${link}`;
|
|
65
75
|
}
|
|
66
|
-
|
package/lib/readify.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const process = require('node:process');
|
|
4
|
+
const isUndefined = (a) => typeof a === 'undefined';
|
|
3
5
|
const format = require('format-io');
|
|
4
6
|
const currify = require('currify');
|
|
5
7
|
const tryToCatch = require('try-to-catch');
|
|
@@ -9,12 +11,10 @@ const formatify = require('@cloudcmd/formatify');
|
|
|
9
11
|
|
|
10
12
|
const WIN = process.platform === 'win32';
|
|
11
13
|
|
|
12
|
-
const ifRaw = currify(_ifRaw);
|
|
13
|
-
const replaceProperty = currify(_replaceProperty);
|
|
14
|
-
|
|
15
|
-
const nicki = !WIN && require('nicki');
|
|
16
|
-
|
|
17
14
|
const readdir = require('./readdir');
|
|
15
|
+
const nicki = !WIN && require('nicki');
|
|
16
|
+
const replaceProperty = currify(_replaceProperty);
|
|
17
|
+
const ifRaw = currify(_ifRaw);
|
|
18
18
|
const isString = (a) => typeof a === 'string';
|
|
19
19
|
|
|
20
20
|
module.exports = readify;
|
|
@@ -97,7 +97,7 @@ function _replaceProperty(obj, prop, item) {
|
|
|
97
97
|
const n = item[prop];
|
|
98
98
|
const data = obj[n];
|
|
99
99
|
|
|
100
|
-
if (
|
|
100
|
+
if (isUndefined(data))
|
|
101
101
|
return item;
|
|
102
102
|
|
|
103
103
|
return {
|
|
@@ -105,4 +105,3 @@ function _replaceProperty(obj, prop, item) {
|
|
|
105
105
|
[prop]: data,
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "readify",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
|
+
"type": "commonjs",
|
|
4
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
6
|
"description": "Read directory content with file attributes: size, date, owner, mode",
|
|
6
7
|
"homepage": "http://github.com/coderaiser/readify",
|
|
@@ -43,20 +44,18 @@
|
|
|
43
44
|
"license": "MIT",
|
|
44
45
|
"main": "lib/readify.js",
|
|
45
46
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
47
|
+
"node": ">=18"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"eslint": "^
|
|
52
|
-
"eslint-plugin-
|
|
53
|
-
"
|
|
54
|
-
"madrun": "^8.0.0",
|
|
50
|
+
"c8": "^9.1.0",
|
|
51
|
+
"eslint": "^8.57.0",
|
|
52
|
+
"eslint-plugin-n": "^16.6.2",
|
|
53
|
+
"eslint-plugin-putout": "^22.5.0",
|
|
54
|
+
"madrun": "^10.0.1",
|
|
55
55
|
"mock-require": "^3.0.2",
|
|
56
|
-
"nodemon": "^
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"supertape": "^4.4.0",
|
|
56
|
+
"nodemon": "^3.1.0",
|
|
57
|
+
"putout": "^35.7.6",
|
|
58
|
+
"supertape": "^10.5.0",
|
|
60
59
|
"try-catch": "^3.0.0"
|
|
61
60
|
},
|
|
62
61
|
"publishConfig": {
|