Skip to content

Commit c7a3fd4

Browse files
committed
Named export only, no default export
1 parent 04bcedf commit c7a3fd4

File tree

12 files changed

+89
-76
lines changed

12 files changed

+89
-76
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 5.0
2+
3+
- No default export, only named exports
4+
15
# 4.4
26

37
- Provide Dirent or Stats object as second argument to filter

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ Install with `npm install rimraf`.
2222
Hybrid module, load either with `import` or `require()`.
2323

2424
```js
25-
// default export is the main rimraf function, or use named imports
26-
import rimraf from 'rimraf'
27-
// or
28-
const rimraf = require('rimraf')
29-
30-
// other strategies exported as well
25+
// 'rimraf' export is the one you probably want, but other
26+
// strategies exported as well.
3127
import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'
3228
// or
3329
const { rimraf, rimrafSync, native, nativeSync } = require('rimraf')

benchmark/create-fixture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { writeFile: writeFile_ } = require('fs')
22
const writeFile = async (path, data) => new Promise((res, rej) =>
33
writeFile_(path, data, er => er ? rej(er) : res()))
4-
const mkdirp = require('mkdirp')
4+
const { mkdirp } = require('mkdirp')
55
const { resolve } = require('path')
66

77
const create = async (path, start, end, maxDepth, depth = 0) => {

libtap-settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// use this module for tap's recursive directory removal, so that
22
// the windows tests don't fail with EBUSY.
3-
const rimraf = require('./')
3+
const { rimraf } = require('./')
44
module.exports = {
55
rmdirRecursiveSync: path => rimraf.sync(path),
66
rmdirRecursive(path, cb) {

package-lock.json

Lines changed: 44 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rimraf",
33
"version": "4.4.1",
4-
"main": "./dist/cjs/src/index-cjs.js",
4+
"main": "./dist/cjs/src/index.js",
55
"module": "./dist/mjs/index.js",
66
"types": "./dist/mjs/index.d.ts",
77
"bin": "./dist/cjs/src/bin.js",
@@ -13,7 +13,7 @@
1313
},
1414
"require": {
1515
"types": "./dist/cjs/src/index.d.ts",
16-
"default": "./dist/cjs/src/index-cjs.js"
16+
"default": "./dist/cjs/src/index.js"
1717
}
1818
}
1919
},
@@ -55,7 +55,7 @@
5555
"@types/tap": "^15.0.7",
5656
"c8": "^7.12.0",
5757
"eslint-config-prettier": "^8.6.0",
58-
"mkdirp": "1",
58+
"mkdirp": "^3.0.0",
5959
"prettier": "^2.8.2",
6060
"tap": "^16.3.4",
6161
"ts-node": "^10.9.1",
@@ -79,6 +79,6 @@
7979
"node": ">=14"
8080
},
8181
"dependencies": {
82-
"glob": "^9.2.0"
82+
"glob": "^10.0.0"
8383
}
8484
}

src/bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import { version } from '../package.json'
3-
import rimraf from './index-cjs.js'
3+
import { rimraf } from './index.js'
44
import type { RimrafAsyncOptions } from './index.js'
55

66
const runHelpForUsage = () =>

src/index-cjs.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/index.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,22 @@ export const rimrafSync = wrapSync((path, opt) =>
111111
)
112112
export const sync = rimrafSync
113113

114-
export const rimraf = Object.assign(
115-
wrap((path, opt) =>
116-
useNative(opt) ? rimrafNative(path, opt) : rimrafManual(path, opt)
117-
),
118-
{
119-
// this weirdness because it's easier than explicitly declaring
120-
rimraf: manual,
121-
sync: rimrafSync,
122-
rimrafSync: rimrafSync,
123-
manual,
124-
manualSync,
125-
native,
126-
nativeSync,
127-
posix,
128-
posixSync,
129-
windows,
130-
windowsSync,
131-
moveRemove,
132-
moveRemoveSync,
133-
}
114+
const rimraf_ = wrap((path, opt) =>
115+
useNative(opt) ? rimrafNative(path, opt) : rimrafManual(path, opt)
134116
)
117+
export const rimraf = Object.assign(rimraf_, {
118+
rimraf: rimraf_,
119+
sync: rimrafSync,
120+
rimrafSync: rimrafSync,
121+
manual,
122+
manualSync,
123+
native,
124+
nativeSync,
125+
posix,
126+
posixSync,
127+
windows,
128+
windowsSync,
129+
moveRemove,
130+
moveRemoveSync,
131+
})
135132
rimraf.rimraf = rimraf
136-
137-
export default rimraf

test/bin.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { basename } = require('path')
21
const t = require('tap')
32
const { readdirSync } = require('fs')
43

@@ -14,15 +13,22 @@ t.test('basic arg parsing stuff', t => {
1413
console.error = (...msg) => ERRS.push(msg)
1514

1615
const CALLS = []
17-
const rimraf = async (path, opt) => CALLS.push(['rimraf', path, opt])
18-
const bin = t.mock('../dist/cjs/src/bin.js', {
19-
'../dist/cjs/src/index.js': Object.assign(rimraf, {
16+
const rimraf = Object.assign(
17+
async (path, opt) => CALLS.push(['rimraf', path, opt]),
18+
{
2019
native: async (path, opt) => CALLS.push(['native', path, opt]),
2120
manual: async (path, opt) => CALLS.push(['manual', path, opt]),
2221
posix: async (path, opt) => CALLS.push(['posix', path, opt]),
2322
windows: async (path, opt) => CALLS.push(['windows', path, opt]),
2423
moveRemove: async (path, opt) => CALLS.push(['move-remove', path, opt]),
25-
}),
24+
}
25+
)
26+
27+
const bin = t.mock('../dist/cjs/src/bin.js', {
28+
'../dist/cjs/src/index.js': {
29+
rimraf,
30+
...rimraf,
31+
},
2632
}).default
2733

2834
t.afterEach(() => {
@@ -264,7 +270,7 @@ t.test('actually delete something with it', async t => {
264270
const bin = require.resolve('../dist/cjs/src/bin.js')
265271
const { spawnSync } = require('child_process')
266272
const res = spawnSync(process.execPath, [bin, path])
267-
const { statSync, readdirSync } = require('fs')
273+
const { statSync } = require('fs')
268274
t.throws(() => statSync(path))
269275
t.equal(res.status, 0)
270276
})

0 commit comments

Comments
 (0)