Skip to content

Commit be1e7b2

Browse files
authored
fix: remove polyfills which are out of range of our engines (#35)
The polyfills removed are: - file-url-to-path.js - mkdir.js
1 parent 957d1ac commit be1e7b2

File tree

13 files changed

+29
-560
lines changed

13 files changed

+29
-560
lines changed

lib/common/file-url-to-path/index.js

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

lib/common/file-url-to-path/polyfill.js

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

lib/common/owner-sync.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { dirname, resolve } = require('path')
2+
const url = require('url')
23

3-
const fileURLToPath = require('./file-url-to-path/index.js')
44
const fs = require('../fs.js')
55

66
// given a path, find the owner of the nearest parent
@@ -13,7 +13,7 @@ const find = (path) => {
1313
// fs methods accept URL objects with a scheme of file: so we need to unwrap
1414
// those into an actual path string before we can resolve it
1515
const resolved = path != null && path.href && path.origin
16-
? resolve(fileURLToPath(path))
16+
? resolve(url.fileURLToPath(path))
1717
: resolve(path)
1818

1919
let stat

lib/common/owner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { dirname, resolve } = require('path')
2+
const url = require('url')
23

3-
const fileURLToPath = require('./file-url-to-path/index.js')
44
const fs = require('../fs.js')
55

66
// given a path, find the owner of the nearest parent
@@ -13,7 +13,7 @@ const find = async (path) => {
1313
// fs methods accept URL objects with a scheme of file: so we need to unwrap
1414
// those into an actual path string before we can resolve it
1515
const resolved = path != null && path.href && path.origin
16-
? resolve(fileURLToPath(path))
16+
? resolve(url.fileURLToPath(path))
1717
: resolve(path)
1818

1919
let stat

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
...require('./fs.js'),
33
copyFile: require('./copy-file.js'),
44
cp: require('./cp/index.js'),
5-
mkdir: require('./mkdir/index.js'),
5+
mkdir: require('./mkdir.js'),
66
mkdtemp: require('./mkdtemp.js'),
77
rm: require('./rm/index.js'),
88
withTempDir: require('./with-temp-dir.js'),

lib/mkdir.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const fs = require('./fs.js')
2+
const getOptions = require('./common/get-options.js')
3+
const withOwner = require('./with-owner.js')
4+
5+
// extends mkdir with the ability to specify an owner of the new dir
6+
const mkdir = async (path, opts) => {
7+
const options = getOptions(opts, {
8+
copy: ['mode', 'recursive'],
9+
wrap: 'mode',
10+
})
11+
12+
return withOwner(
13+
path,
14+
() => fs.mkdir(path, options),
15+
opts
16+
)
17+
}
18+
19+
module.exports = mkdir

lib/mkdir/index.js

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

lib/mkdir/polyfill.js

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

lib/with-temp-dir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { join, sep } = require('path')
22

33
const getOptions = require('./common/get-options.js')
4-
const mkdir = require('./mkdir/index.js')
4+
const mkdir = require('./mkdir.js')
55
const mkdtemp = require('./mkdtemp.js')
66
const rm = require('./rm/index.js')
77

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const t = require('tap')
2-
3-
const fileURLToPath = require('../../../lib/common/file-url-to-path/index.js')
2+
const url = require('url')
43

54
t.test('can convert a file url to a path', async (t) => {
6-
const url = process.platform === 'win32'
5+
const u = process.platform === 'win32'
76
? 'file://c:/some/path' // windows requires an absolute path, or hostname
87
: 'file:///some/path' // posix cannot have a hostname
9-
const path = fileURLToPath(url)
8+
const path = url.fileURLToPath(u)
109
t.type(path, 'string', 'result is a string')
1110
})

0 commit comments

Comments
 (0)