Skip to content

Commit 624f609

Browse files
committed
Inline slash dependency (latest major was ESM-only) #4
1 parent 62c5b5a commit 624f609

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

lib/copy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var EventEmitter = require('node:events').EventEmitter;
66
var fs = require('fs');
77
var junk = require('junk');
88
var errno = require('errno');
9-
var slash = require('slash');
9+
var slash = require('./slash.js');
1010
var maximatch = require('./maximatch.js');
1111

1212
var CopyError = errno.custom.createError('CopyError');

lib/slash.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// via https://github.com/sindresorhus/slash/blob/main/index.js (MIT license)
2+
module.exports = function slash(path) {
3+
const isExtendedLengthPath = path.startsWith('\\\\?\\');
4+
5+
if (isExtendedLengthPath) {
6+
return path;
7+
}
8+
9+
return path.replace(/\\/g, '/');
10+
}

package-lock.json

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

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
"dependencies": {
5555
"errno": "^1.0.0",
5656
"junk": "^3.1.0",
57-
"minimatch": "^10.1.1",
58-
"slash": "^3.0.0"
57+
"minimatch": "^10.1.1"
5958
},
6059
"devDependencies": {
6160
"@types/node": "^14.18.63",

test/spec/copy.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ var path = require('node:path');
66
var chai = require('chai');
77
var expect = chai.expect;
88
var chaiAsPromised = require('chai-as-promised');
9-
var slash = require('slash');
109
var readDirFiles = require('read-dir-files');
1110
var through = require('through2');
1211
var rewire = require('rewire');
1312

13+
var slash = require('../../lib/slash.js');
1414
var copy = rewire('../../lib/copy');
1515

1616
var SOURCE_PATH = path.resolve(__dirname, '../fixtures/source');

0 commit comments

Comments
 (0)