Skip to content

Commit cfdb9cd

Browse files
committed
feature(trammel) drop support of node < 14
1 parent efbf334 commit cfdb9cd

File tree

8 files changed

+39
-43
lines changed

8 files changed

+39
-43
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"node/no-unsupported-features/node-builtins": "off"
44
},
55
"extends": [
6-
"plugin:putout/recommended",
7-
"plugin:node/recommended"
6+
"plugin:node/recommended",
7+
"plugin:putout/recommended"
88
],
99
"plugins": [
1010
"putout",

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
*.swp
12
.*.swp
23
.nyc_output
34
node_modules
45
yarn-error.log
56

7+
.putoutcache

.madrun.js renamed to .madrun.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
'use strict';
1+
import {run} from 'madrun';
22

3-
const {run} = require('madrun');
4-
5-
module.exports = {
6-
'lint': () => 'putout lib test .madrun.js',
3+
export default {
4+
'lint': () => 'putout .',
5+
'fresh:lint': () => run('lint', '--fresh'),
6+
'lint:fresh': () => run('lint', '--fresh'),
77
'fix:lint': () => run('lint', '--fix'),
88
'report': () => 'nyc report --reporter=text-lcov | coveralls',
99
'coverage': () => 'nyc npm test',

.travis.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
language: node_js
22
node_js:
3-
- 14
4-
- 12
5-
- 10
6-
3+
- 15
4+
- 14
75
script:
86
- npm run lint
97
- npm run coverage && npm run report
10-
118
notifications:
12-
email:
13-
on_success: never
14-
on_failure: change
15-
9+
email:
10+
on_success: never
11+
on_failure: change
1612
sudo: false
17-
13+
cache: false

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Trammel [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL]
22

3-
[NPMIMGURL]: https://img.shields.io/npm/v/trammel.svg?style=flat
4-
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/trammel/master.svg?style=flat
5-
[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/trammel.svg?style=flat
6-
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
7-
[NPMURL]: https://npmjs.org/package/trammel "npm"
8-
[BuildStatusURL]: https://travis-ci.org/coderaiser/trammel "Build Status"
9-
[DependencyStatusURL]: https://david-dm.org/coderaiser/trammel "Dependency Status"
10-
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
3+
[NPMIMGURL]: https://img.shields.io/npm/v/trammel.svg?style=flat
4+
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/trammel/master.svg?style=flat
5+
[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/trammel.svg?style=flat
6+
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
7+
[NPMURL]: https://npmjs.org/package/trammel "npm"
8+
[BuildStatusURL]: https://travis-ci.org/coderaiser/trammel "Build Status"
9+
[DependencyStatusURL]: https://david-dm.org/coderaiser/trammel "Dependency Status"
10+
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
1111

1212
Get directory size.
1313

@@ -20,18 +20,17 @@ import trammel from 'trammel';
2020

2121
await trammel('.');
2222
// returns
23-
'58.47kb'
23+
'58.47kb';
2424

2525
await trammel('.', {type: 'raw'});
2626
// returns
27-
59974
27+
59_974;
2828

2929
await trammel('do not exist', {stopOnError: true});
3030
// throws
31-
Error
31+
Error;
3232
```
3333

3434
## License
3535

3636
MIT
37-

lib/trammel.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const {promisify} = require('util');
4-
const {lstat, readdir} = require('fs').promises;
4+
const {lstat, readdir} = require('fs/promises');
55
const path = require('path');
66
const {EventEmitter} = require('events');
77

@@ -14,7 +14,7 @@ const tryToCatch = require('try-to-catch');
1414
information about the file the link references.
1515
*/
1616

17-
module.exports = promisify((dir, options, callback) => {
17+
module.exports = promisify(async (dir, options, callback) => {
1818
const emitter = new EventEmitter();
1919

2020
let total = 0;
@@ -40,10 +40,10 @@ module.exports = promisify((dir, options, callback) => {
4040
callback(null, format.size(total));
4141
});
4242

43-
processDir(dir, options, emitter);
43+
await processDir(dir, options, emitter);
4444
});
4545

46-
function processDir(dir, options, emitter) {
46+
async function processDir(dir, options, emitter) {
4747
const {stopOnError} = options;
4848
let wasError = false;
4949
let asyncRunning = 0;
@@ -59,7 +59,7 @@ function processDir(dir, options, emitter) {
5959
emitter.emit('end');
6060
};
6161

62-
getDirInfo(dir);
62+
await getDirInfo(dir);
6363

6464
async function getDirInfo(dir) {
6565
const [error, stat] = await tryToCatch(lstat, dir);
@@ -92,7 +92,7 @@ function processDir(dir, options, emitter) {
9292
asyncRunning--;
9393

9494
if (!readError)
95-
return onReaddir(dir, files);
95+
return await onReaddir(dir, files);
9696

9797
if (readError && stopOnError) {
9898
wasError = true;
@@ -102,7 +102,7 @@ function processDir(dir, options, emitter) {
102102
execCallBack();
103103
}
104104

105-
function onReaddir(dir, files) {
105+
async function onReaddir(dir, files) {
106106
const n = files.length;
107107

108108
fileCounter += n;
@@ -112,7 +112,7 @@ function processDir(dir, options, emitter) {
112112

113113
for (const file of files) {
114114
const dirPath = path.join(dir, file);
115-
getDirInfo(dirPath);
115+
await getDirInfo(dirPath);
116116
}
117117
}
118118
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"watcher": "madrun watcher"
2222
},
2323
"dependencies": {
24-
"events.once": "^2.0.2",
2524
"format-io": "^2.0.0",
2625
"try-to-catch": "^3.0.0"
2726
},
@@ -35,11 +34,11 @@
3534
"nodemon": "^2.0.7",
3635
"nyc": "^15.0.1",
3736
"putout": "^13.7.1",
38-
"supertape": "^1.2.3"
37+
"supertape": "^4.7.0"
3938
},
4039
"license": "MIT",
4140
"engines": {
42-
"node": ">=10"
41+
"node": ">=14"
4342
},
4443
"main": "lib/trammel.js",
4544
"publishConfig": {

test/trammel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ test('trammel: size of a file', async (t) => {
1515
const expected = '12b';
1616
const [, size] = await tryToCatch(trammel, `${fixturePath}/file.txt`);
1717

18-
t.equal(expected, size, 'should equal');
18+
t.equal(size, expected, 'should equal');
1919
t.end();
2020
});
2121

2222
test('trammel: size of a directory', async (t) => {
2323
const expected = '12b';
2424
const [, size] = await tryToCatch(trammel, `${fixturePath}/dir`);
2525

26-
t.equal(expected, size, 'should equal');
26+
t.equal(size, expected, 'should equal');
2727
t.end();
2828
});
2929

@@ -33,7 +33,7 @@ test('trammel: size of a directory: empty dir: raw', async (t) => {
3333
type: 'raw',
3434
});
3535

36-
t.equal(expected, size, 'should equal');
36+
t.equal(size, expected, 'should equal');
3737
t.end();
3838
});
3939

0 commit comments

Comments
 (0)