Skip to content

Commit

Permalink
fix: remove polyfills which are out of range of our engines (#35)
Browse files Browse the repository at this point in the history
The polyfills removed are:
- file-url-to-path.js
- mkdir.js
  • Loading branch information
lukekarrys committed Jul 20, 2022
1 parent 957d1ac commit be1e7b2
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 560 deletions.
17 changes: 0 additions & 17 deletions lib/common/file-url-to-path/index.js

This file was deleted.

121 changes: 0 additions & 121 deletions lib/common/file-url-to-path/polyfill.js

This file was deleted.

4 changes: 2 additions & 2 deletions lib/common/owner-sync.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { dirname, resolve } = require('path')
const url = require('url')

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

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

let stat
Expand Down
4 changes: 2 additions & 2 deletions lib/common/owner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { dirname, resolve } = require('path')
const url = require('url')

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

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

let stat
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
...require('./fs.js'),
copyFile: require('./copy-file.js'),
cp: require('./cp/index.js'),
mkdir: require('./mkdir/index.js'),
mkdir: require('./mkdir.js'),
mkdtemp: require('./mkdtemp.js'),
rm: require('./rm/index.js'),
withTempDir: require('./with-temp-dir.js'),
Expand Down
19 changes: 19 additions & 0 deletions lib/mkdir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('./fs.js')
const getOptions = require('./common/get-options.js')
const withOwner = require('./with-owner.js')

// extends mkdir with the ability to specify an owner of the new dir
const mkdir = async (path, opts) => {
const options = getOptions(opts, {
copy: ['mode', 'recursive'],
wrap: 'mode',
})

return withOwner(
path,
() => fs.mkdir(path, options),
opts
)
}

module.exports = mkdir
29 changes: 0 additions & 29 deletions lib/mkdir/index.js

This file was deleted.

81 changes: 0 additions & 81 deletions lib/mkdir/polyfill.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/with-temp-dir.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { join, sep } = require('path')

const getOptions = require('./common/get-options.js')
const mkdir = require('./mkdir/index.js')
const mkdir = require('./mkdir.js')
const mkdtemp = require('./mkdtemp.js')
const rm = require('./rm/index.js')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const t = require('tap')

const fileURLToPath = require('../../../lib/common/file-url-to-path/index.js')
const url = require('url')

t.test('can convert a file url to a path', async (t) => {
const url = process.platform === 'win32'
const u = process.platform === 'win32'
? 'file://c:/some/path' // windows requires an absolute path, or hostname
: 'file:///some/path' // posix cannot have a hostname
const path = fileURLToPath(url)
const path = url.fileURLToPath(u)
t.type(path, 'string', 'result is a string')
})

0 comments on commit be1e7b2

Please sign in to comment.