Skip to content

Commit

Permalink
fix: replace deprecated String.prototype.substr() (#85)
Browse files Browse the repository at this point in the history
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
  • Loading branch information
CommanderRoot authored Apr 5, 2022
1 parent f787fe8 commit 79d6f7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Walker extends IgnoreWalker {
// hierarchy (ie, not in test/foo/node_modules/ or something).
const followRe = /^(?:\/node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\/)*\/node_modules(?:\/@[^/]+)?$/
const rootPath = opt.parent ? opt.parent.root : opt.path
const followTestPath = opt.path.replace(/\\/g, '/').substr(rootPath.length)
const followTestPath = opt.path.replace(/\\/g, '/').slice(rootPath.length)
opt.follow = followRe.test(followTestPath)

super(opt)
Expand Down Expand Up @@ -239,7 +239,7 @@ class Walker extends IgnoreWalker {
const patterns = Array.from(new Set(pkg.files)).reduce((set, pattern) => {
const excl = pattern.match(/^!+/)
if (excl) {
pattern = pattern.substr(excl[0].length)
pattern = pattern.slice(excl[0].length)
}
// strip off any / from the start of the pattern. /foo => foo
pattern = pattern.replace(/^\/+/, '')
Expand Down Expand Up @@ -298,7 +298,7 @@ class Walker extends IgnoreWalker {

filterEntry (entry, partial) {
// get the partial path from the root of the walk
const p = this.path.substr(this.root.length + 1)
const p = this.path.slice(this.root.length + 1)
const { isProject } = this
const pkg = isProject && pathHasPkg(entry)
? pkgFromPath(entry)
Expand Down

0 comments on commit 79d6f7e

Please sign in to comment.