Skip to content

Commit 7631a85

Browse files
authoredJul 9, 2021
Fix finding missing paths
Closes GH-51. Closes GH-52.
1 parent 8d4b390 commit 7631a85

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed
 

‎lib/finder.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ function expand(input, options, next) {
105105
paths.push(file)
106106
}
107107
} else {
108+
const fp = file.path ? path.relative(options.cwd, file.path) : options.cwd
108109
file.cwd = options.cwd
109-
file.path = path.relative(options.cwd, file.path)
110-
file.history = [file.path]
110+
file.path = fp
111+
file.history = [fp]
111112
paths.push(file)
112113
}
113114
}

‎test/input.js

+30-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {engine} from '../index.js'
1111
const fixtures = path.join('test', 'fixtures')
1212

1313
test('input', (t) => {
14-
t.plan(19)
14+
t.plan(20)
1515

1616
t.test('should fail without input', (t) => {
1717
const stream = new PassThrough()
@@ -364,7 +364,7 @@ test('input', (t) => {
364364
)
365365
})
366366

367-
t.test('should not atempt to read files with `value` (1)', (t) => {
367+
t.test('should not attempt to read files with `value` (1)', (t) => {
368368
const stderr = spy()
369369
const cwd = path.join(fixtures, 'ignore-file')
370370
const file = toVFile({
@@ -400,7 +400,7 @@ test('input', (t) => {
400400
)
401401
})
402402

403-
t.test('should not atempt to read files with `value` (2)', (t) => {
403+
t.test('should not attempt to read files with `value` (2)', (t) => {
404404
const stderr = spy()
405405
const cwd = path.join(fixtures, 'ignore-file')
406406
const file = toVFile({
@@ -428,6 +428,33 @@ test('input', (t) => {
428428
)
429429
})
430430

431+
t.test('should not attempt to read files with `value` (3)', (t) => {
432+
const stderr = spy()
433+
const cwd = path.join(fixtures, 'empty')
434+
const file = toVFile({value: 'foo'})
435+
436+
t.plan(1)
437+
438+
engine(
439+
{processor: noop, cwd, streamError: stderr.stream, files: [file]},
440+
(error, code) => {
441+
t.deepEqual(
442+
[error, code, stderr()],
443+
[
444+
null,
445+
0,
446+
'test' +
447+
path.sep +
448+
'fixtures' +
449+
path.sep +
450+
'empty: no issues found\n'
451+
],
452+
'should report'
453+
)
454+
}
455+
)
456+
})
457+
431458
t.test('should include given ignored files (#2)', (t) => {
432459
const stderr = spy()
433460

0 commit comments

Comments
 (0)
Please sign in to comment.