Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
fix: replace deprecated String.prototype.substr() (#59)
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 committed Apr 5, 2022
1 parent 109af89 commit 43893b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/env-replace.js
Expand Up @@ -7,8 +7,8 @@ module.exports = (f, env) => f.replace(envExpr, (orig, esc, name) => {

// consume the escape chars that are relevant.
if (esc.length % 2) {
return orig.substr((esc.length + 1) / 2)
return orig.slice((esc.length + 1) / 2)
}

return (esc.substr(esc.length / 2)) + val
return (esc.slice(esc.length / 2)) + val
})
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -366,7 +366,7 @@ class Config {
if (!/^npm_config_/i.test(envKey) || envVal === '') {
continue
}
const key = envKey.substr('npm_config_'.length)
const key = envKey.slice('npm_config_'.length)
.replace(/(?!^)_/g, '-') // don't replace _ at the start of the key
.toLowerCase()
conf[key] = envVal
Expand Down
2 changes: 1 addition & 1 deletion lib/parse-field.js
Expand Up @@ -56,7 +56,7 @@ const parseField = (f, key, opts, listElement = false) => {
if (isPath) {
const homePattern = platform === 'win32' ? /^~(\/|\\)/ : /^~\//
if (homePattern.test(f) && home) {
f = resolve(home, f.substr(2))
f = resolve(home, f.slice(2))
} else {
f = resolve(f)
}
Expand Down

0 comments on commit 43893b6

Please sign in to comment.