Skip to content

Commit c4dc8d6

Browse files
committed
refactor: remove unnecessary padEnd & padStart shims
Both features are already supported in Node.js v8+
1 parent 7a835df commit c4dc8d6

File tree

5 files changed

+3
-25
lines changed

5 files changed

+3
-25
lines changed

packages/@vue/cli-service/lib/commands/help.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { chalk } = require('@vue/cli-shared-utils')
2-
const padEnd = require('string.prototype.padend')
32
const getPadLength = require('../util/getPadLength')
43

54
module.exports = (api, options) => {
@@ -23,7 +22,7 @@ module.exports = (api, options) => {
2322
if (name !== 'help') {
2423
const opts = commands[name].opts || {}
2524
console.log(` ${
26-
chalk.blue(padEnd(name, padLength))
25+
chalk.blue(name.padEnd(padLength))
2726
}${
2827
opts.description || ''
2928
}`)
@@ -47,7 +46,7 @@ module.exports = (api, options) => {
4746
const padLength = getPadLength(opts.options)
4847
for (const [flags, description] of Object.entries(opts.options)) {
4948
console.log(` ${
50-
chalk.blue(padEnd(flags, padLength))
49+
chalk.blue(flags.padEnd(padLength))
5150
}${
5251
description
5352
}`)

packages/@vue/cli-service/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"read-pkg": "^5.1.1",
6767
"slash": "^3.0.0",
6868
"ssri": "^7.1.0",
69-
"string.prototype.padend": "^3.0.0",
7069
"terser-webpack-plugin": "^2.2.1",
7170
"thread-loader": "^2.1.3",
7271
"url-loader": "^2.2.0",

packages/@vue/cli-shared-utils/lib/logger.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const chalk = require('chalk')
22
const stripAnsi = require('strip-ansi')
33
const readline = require('readline')
4-
const padStart = require('string.prototype.padstart')
54
const EventEmitter = require('events')
65

76
exports.events = new EventEmitter()
@@ -20,7 +19,7 @@ const format = (label, msg) => {
2019
return msg.split('\n').map((line, i) => {
2120
return i === 0
2221
? `${label} ${line}`
23-
: padStart(line, stripAnsi(label).length)
22+
: line.padStart(stripAnsi(label).length)
2423
}).join('\n')
2524
}
2625

packages/@vue/cli-shared-utils/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"request": "^2.87.0",
3232
"request-promise-native": "^1.0.8",
3333
"semver": "^6.1.0",
34-
"string.prototype.padstart": "^3.0.0",
3534
"strip-ansi": "^6.0.0"
3635
},
3736
"publishConfig": {

yarn.lock

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15891,24 +15891,6 @@ string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0:
1589115891
is-fullwidth-code-point "^3.0.0"
1589215892
strip-ansi "^6.0.0"
1589315893

15894-
string.prototype.padend@^3.0.0:
15895-
version "3.0.0"
15896-
resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz#f3aaef7c1719f170c5eab1c32bf780d96e21f2f0"
15897-
integrity sha1-86rvfBcZ8XDF6rHDK/eA2W4h8vA=
15898-
dependencies:
15899-
define-properties "^1.1.2"
15900-
es-abstract "^1.4.3"
15901-
function-bind "^1.0.2"
15902-
15903-
string.prototype.padstart@^3.0.0:
15904-
version "3.0.0"
15905-
resolved "https://registry.yarnpkg.com/string.prototype.padstart/-/string.prototype.padstart-3.0.0.tgz#5bcfad39f4649bb2d031292e19bcf0b510d4b242"
15906-
integrity sha1-W8+tOfRkm7LQMSkuGbzwtRDUskI=
15907-
dependencies:
15908-
define-properties "^1.1.2"
15909-
es-abstract "^1.4.3"
15910-
function-bind "^1.0.2"
15911-
1591215894
string.prototype.trimleft@^2.1.0:
1591315895
version "2.1.0"
1591415896
resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz#6cc47f0d7eb8d62b0f3701611715a3954591d634"

0 commit comments

Comments
 (0)