esupgrade 2025.18.0 → 2025.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/esupgrade.js
CHANGED
|
@@ -58,6 +58,7 @@ class FileProcessor {
|
|
|
58
58
|
* @param {string} options.baseline - Baseline level for transformations.
|
|
59
59
|
* @param {boolean} options.check - Whether to only check for changes.
|
|
60
60
|
* @param {boolean} options.write - Whether to write changes to file.
|
|
61
|
+
* @param {boolean} options.verbose - The verbosity level for logging.
|
|
61
62
|
* @param {boolean} options.jQuery - Whether to include jQuery transformers.
|
|
62
63
|
* @returns {Promise<{modified: boolean, error: boolean}>} Result of processing.
|
|
63
64
|
*/
|
|
@@ -82,7 +83,10 @@ class FileProcessor {
|
|
|
82
83
|
)
|
|
83
84
|
|
|
84
85
|
if (!workerResult.success) {
|
|
85
|
-
console.error(
|
|
86
|
+
if (options.verbose) console.error(workerResult.error)
|
|
87
|
+
console.error(
|
|
88
|
+
`\x1b[31m✗\x1b[0m Error: ${filePath}: ${workerResult.error.message}`,
|
|
89
|
+
)
|
|
86
90
|
return { modified: false, error: true }
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -266,6 +270,7 @@ program
|
|
|
266
270
|
.choices(["widely-available", "newly-available"])
|
|
267
271
|
.default("widely-available"),
|
|
268
272
|
)
|
|
273
|
+
.option("--verbose, -v", "Show more detailed output.", false)
|
|
269
274
|
.option(
|
|
270
275
|
"--check",
|
|
271
276
|
"Report which files need upgrading and exit with code 1 if any do",
|
package/package.json
CHANGED
package/src/types.js
CHANGED
|
@@ -293,6 +293,10 @@ export class NodeTest {
|
|
|
293
293
|
* @returns {boolean} True if predicate returned true for any node
|
|
294
294
|
*/
|
|
295
295
|
#traverseForPredicate(astNode, predicate) {
|
|
296
|
+
if (!astNode) {
|
|
297
|
+
return false
|
|
298
|
+
}
|
|
299
|
+
|
|
296
300
|
if (predicate(astNode)) {
|
|
297
301
|
return true
|
|
298
302
|
}
|
package/src/worker.js
CHANGED
package/tests/cli.test.js
CHANGED
|
@@ -542,4 +542,30 @@ describe("CLI", () => {
|
|
|
542
542
|
)
|
|
543
543
|
assert.equal(resultWithJQuery.status, 0, "exits successfully with --jQuery")
|
|
544
544
|
})
|
|
545
|
+
|
|
546
|
+
test("show error message without stack trace at default verbosity", () => {
|
|
547
|
+
const testFile = path.join(tempDir, "test.js")
|
|
548
|
+
fs.writeFileSync(testFile, `var x = {{{;`)
|
|
549
|
+
|
|
550
|
+
const result = spawnSync(process.execPath, [CLI_PATH, testFile], {
|
|
551
|
+
encoding: "utf8",
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
assert.match(result.stderr, /Error:/, "displays error message")
|
|
555
|
+
assert.doesNotMatch(result.stderr, /\n\s*at /, "omits stack trace")
|
|
556
|
+
})
|
|
557
|
+
|
|
558
|
+
test("show full error with stack trace with --verbose", () => {
|
|
559
|
+
const testFile = path.join(tempDir, "test.js")
|
|
560
|
+
fs.writeFileSync(testFile, `var x = {{{;`)
|
|
561
|
+
|
|
562
|
+
const result = spawnSync(
|
|
563
|
+
process.execPath,
|
|
564
|
+
[CLI_PATH, testFile, "--verbose", "--verbose"],
|
|
565
|
+
{ encoding: "utf8" },
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
assert.match(result.stderr, /Error:/, "displays error message")
|
|
569
|
+
assert.match(result.stderr, /\n\s*at /, "includes stack trace at verbosity level 2")
|
|
570
|
+
})
|
|
545
571
|
})
|
|
@@ -116,6 +116,15 @@ suite("widely-available", () => {
|
|
|
116
116
|
assert.match(result.code, /console\.info\('test'\)/)
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
+
test("arrow function with array destructuring holes in body", () => {
|
|
120
|
+
const result = transform(
|
|
121
|
+
`const f = (arr) => { const [a, , b] = arr; return a + b; }`,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
assert(result.modified, "transform arrow function with array holes in body")
|
|
125
|
+
assert.match(result.code, /function f\(arr\)/)
|
|
126
|
+
})
|
|
127
|
+
|
|
119
128
|
test("skip arrow function using this", () => {
|
|
120
129
|
const result = transform(`const method = () => { return this.value; }`)
|
|
121
130
|
|