Skip to content

Commit 010bdfc

Browse files
committed
Update unified-engine, unified, etc
1 parent c545bbd commit 010bdfc

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function args(cliConfig) {
3333
let config
3434
/** @type {chokidar.FSWatcher|undefined} */
3535
let watcher
36-
/** @type {boolean|string|undefined} */
36+
/** @type {URL|boolean|string|undefined} */
3737
let output
3838

3939
try {

lib/options.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ export function options(flags, configuration) {
9090
' $ ' + name + ' . -o'
9191
].join('\n')
9292

93+
/** @type {string} */
94+
let key
95+
96+
for (key in config) {
97+
if (config[key] === null) {
98+
config[key] = undefined
99+
}
100+
}
101+
93102
return {
94103
helpMessage: help,
95104
cwd: configuration.cwd,

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@
3232
],
3333
"dependencies": {
3434
"@types/text-table": "^0.2.0",
35-
"camelcase": "^7.0.0",
35+
"camelcase": "^8.0.0",
3636
"chalk": "^5.0.0",
3737
"chokidar": "^3.0.0",
3838
"fault": "^2.0.0",
3939
"json5": "^2.0.0",
4040
"minimist": "^1.0.0",
4141
"text-table": "^0.2.0",
42-
"unified-engine": "^10.0.0"
42+
"unified-engine": "^11.0.0"
4343
},
4444
"devDependencies": {
4545
"@types/minimist": "^1.0.0",
4646
"@types/tape": "^5.0.0",
4747
"@types/touch": "^3.0.0",
4848
"bail": "^2.0.0",
4949
"c8": "^8.0.0",
50-
"execa": "^7.0.0",
50+
"execa": "^8.0.0",
5151
"prettier": "^3.0.0",
5252
"remark": "^14.0.0",
5353
"remark-cli": "^11.0.0",
@@ -58,8 +58,8 @@
5858
"touch": "^3.0.0",
5959
"type-coverage": "^2.0.0",
6060
"typescript": "^5.0.0",
61-
"unified": "^10.0.0",
62-
"vfile-reporter-json": "^3.0.0",
61+
"unified": "^11.0.0",
62+
"vfile-reporter-json": "^4.0.0",
6363
"xo": "^0.56.0"
6464
},
6565
"scripts": {

test/index.js

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import test from 'tape'
1111
import strip from 'strip-ansi'
1212
import touch from 'touch'
1313

14-
const cross = process.platform === 'win32' ? '×' : '✖'
15-
1614
const fixtures = path.join('test', 'fixtures')
1715
const cwd = path.join(fixtures, 'example')
1816
const bin = path.join(cwd, 'cli.js')
@@ -23,9 +21,11 @@ test('unified-args', (t) => {
2321
t.test('should fail on missing files', (t) => {
2422
const expected = [
2523
'missing.txt',
26-
' 1:1 error No such file or directory',
24+
' error No such file or folder',
25+
' [cause]:',
26+
' Error: ENOENT:…',
2727
'',
28-
cross + ' 1 error'
28+
'✖ 1 error'
2929
].join('\n')
3030

3131
t.plan(1)
@@ -34,7 +34,7 @@ test('unified-args', (t) => {
3434
() => t.fail(),
3535
(/** @type {ExecaReturnValue} */ error) => {
3636
t.deepEqual(
37-
[error.exitCode, strip(error.stderr)],
37+
[error.exitCode, cleanError(error.stderr)],
3838
[1, expected],
3939
'should fail'
4040
)
@@ -597,11 +597,11 @@ test('unified-args', (t) => {
597597
t.test('should fail when given an ignored path', (t) => {
598598
const expected = [
599599
'one.txt',
600-
' 1:1 error Cannot process specified file: it’s ignored',
600+
' error Cannot process specified file: it’s ignored',
601601
'',
602602
'two.txt: no issues found',
603603
'',
604-
cross + ' 1 error'
604+
'✖ 1 error'
605605
].join('\n')
606606

607607
t.plan(1)
@@ -780,3 +780,32 @@ test('unified-args', (t) => {
780780

781781
t.end()
782782
})
783+
784+
/**
785+
* Clean an error so that it’s easier to test.
786+
*
787+
* This particularly removed error cause messages, which change across Node
788+
* versions.
789+
* It also drops file paths, which differ across platforms.
790+
*
791+
* @param {string} value
792+
* Error, report, or stack.
793+
* @param {number | undefined} [max=Infinity]
794+
* Lines to include.
795+
* @returns {string}
796+
* Clean error.
797+
*/
798+
function cleanError(value, max) {
799+
return (
800+
strip(value)
801+
// Clean syscal errors
802+
.replace(/( *Error: [A-Z]+:)[^\n]*/g, '$1…')
803+
804+
.replace(/\(.+[/\\]/g, '(')
805+
.replace(/file:.+\//g, '')
806+
.replace(/\d+:\d+/g, '1:1')
807+
.split('\n')
808+
.slice(0, max || Number.POSITIVE_INFINITY)
809+
.join('\n')
810+
)
811+
}

0 commit comments

Comments
 (0)