Skip to content

Commit

Permalink
Fix Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 2, 2023
1 parent 2389f36 commit 8662388
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 101 deletions.
2 changes: 1 addition & 1 deletion lib/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export class Configuration {
async function loadScriptOrModule(_, filePath) {
// Assume it’s a config.
const result = /** @type {Result} */ (
await loadFromAbsolutePath(filePath, this.cwd)
await loadFromAbsolutePath(pathToFileURL(filePath).href, this.cwd)
)
return result
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unified-engine",
"version": "11.1.0",
"version": "11.1.1",
"description": "unified engine to process multiple files, lettings users configure from the file system",
"license": "MIT",
"keywords": [
Expand Down
223 changes: 124 additions & 99 deletions test/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 1)
assert.equal(
cleanError(stderr(), 4),
assert.deepEqual(
[code, cleanError(stderr(), 4)],
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot read given file `.foorc`'
].join('\n')
1,
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot read given file `.foorc`'
].join('\n')
]
)
}
)
Expand All @@ -52,15 +54,17 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 1)
assert.equal(
cleanError(stderr(), 4),
assert.deepEqual(
[code, cleanError(stderr(), 4)],
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse given file `.foorc`'
].join('\n')
1,
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse given file `.foorc`'
].join('\n')
]
)
}
)
Expand All @@ -79,15 +83,17 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 1)
assert.equal(
cleanError(stderr(), 4),
assert.deepEqual(
[code, cleanError(stderr(), 4)],
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse given file `.foorc.js`'
].join('\n')
1,
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse given file `.foorc.js`'
].join('\n')
]
)
}
)
Expand All @@ -103,15 +109,18 @@ test('configuration', async function (t) {
rcName: '.foorc',
streamError: stderr.stream
})
assert.equal(code, 1)
assert.equal(
cleanError(stderr(), 4),

assert.deepEqual(
[code, cleanError(stderr(), 4)],
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `.foorc.js`'
].join('\n')
1,
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `.foorc.js`'
].join('\n')
]
)
})

Expand All @@ -126,8 +135,8 @@ test('configuration', async function (t) {
rcName: '.foorc',
streamError: stderr.stream
})
assert.equal(code, 0)
assert.equal(stderr(), 'one.txt: no issues found\n')

assert.deepEqual([code, stderr()], [0, 'one.txt: no issues found\n'])
})

await t.test('should support `.rc.js` scripts (3)', async function () {
Expand All @@ -141,8 +150,8 @@ test('configuration', async function (t) {
rcName: '.foorc',
streamError: stderr.stream
})
assert.equal(code, 0)
assert.equal(stderr(), 'one.txt: no issues found\n')

assert.deepEqual([code, stderr()], [0, 'one.txt: no issues found\n'])
})

await t.test('should support `.rc.mjs` module', async function () {
Expand All @@ -164,9 +173,10 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 0)
assert.equal(stderr(), 'one.txt: no issues found\n')
assert.equal(calls, 1)
assert.deepEqual(
[code, calls, stderr()],
[0, 1, 'one.txt: no issues found\n']
)
})

await t.test('should support `.rc.cjs` module', async function () {
Expand All @@ -187,9 +197,11 @@ test('configuration', async function (t) {
rcName: '.foorc',
streamError: stderr.stream
})
assert.equal(code, 0)
assert.equal(stderr(), 'one.txt: no issues found\n')
assert.equal(calls, 1)

assert.deepEqual(
[code, calls, stderr()],
[0, 1, 'one.txt: no issues found\n']
)
})

await t.test('should support `.rc.yaml` config files', async function () {
Expand All @@ -203,15 +215,18 @@ test('configuration', async function (t) {
rcName: '.foorc',
streamError: stderr.stream
})
assert.equal(code, 1)
assert.equal(
cleanError(stderr(), 4),

assert.deepEqual(
[code, cleanError(stderr(), 4)],
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `.foorc.yaml`'
].join('\n')
1,
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `.foorc.yaml`'
].join('\n')
]
)
})

Expand All @@ -237,18 +252,20 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 0)
assert.equal(
stderr(),
assert.deepEqual(
[code, calls, stderr()],
[
'nested' + sep + 'four.txt: no issues found',
'nested' + sep + 'three.txt: no issues found',
'one.txt: no issues found',
'two.txt: no issues found',
''
].join('\n')
0,
4,
[
'nested' + sep + 'four.txt: no issues found',
'nested' + sep + 'three.txt: no issues found',
'one.txt: no issues found',
'two.txt: no issues found',
''
].join('\n')
]
)
assert.equal(calls, 4)
})

await t.test('should support searching package files', async function () {
Expand All @@ -263,15 +280,17 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 1)
assert.equal(
cleanError(stderr(), 4),
assert.deepEqual(
[code, cleanError(stderr(), 4)],
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `package.json`'
].join('\n')
1,
[
'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `package.json`'
].join('\n')
]
)
})

Expand All @@ -298,18 +317,20 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 0)
assert.equal(
stderr(),
assert.deepEqual(
[code, calls, stderr()],
[
'nested' + sep + 'four.txt: no issues found',
'nested' + sep + 'three.txt: no issues found',
'one.txt: no issues found',
'two.txt: no issues found',
''
].join('\n')
0,
4,
[
'nested' + sep + 'four.txt: no issues found',
'nested' + sep + 'three.txt: no issues found',
'one.txt: no issues found',
'two.txt: no issues found',
''
].join('\n')
]
)
assert.equal(calls, 4)
})

await t.test('should support no config files', async function () {
Expand All @@ -325,15 +346,17 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 0)
assert.equal(
stderr(),
assert.deepEqual(
[code, stderr()],
[
'nested' + sep + 'three.txt: no issues found',
'nested' + sep + 'two.txt: no issues found',
'one.txt: no issues found',
''
].join('\n')
0,
[
'nested' + sep + 'three.txt: no issues found',
'nested' + sep + 'two.txt: no issues found',
'one.txt: no issues found',
''
].join('\n')
]
)
})

Expand All @@ -352,8 +375,7 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 0)
assert.equal(stderr(), 'one.txt: no issues found\n')
assert.deepEqual([code, stderr()], [0, 'one.txt: no issues found\n'])
}
)

Expand All @@ -374,9 +396,10 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 0)
assert.equal(stderr(), 'one.txt: no issues found\n')
assert.equal(calls, 1)
assert.deepEqual(
[code, calls, stderr()],
[0, 1, 'one.txt: no issues found\n']
)
})

await t.test('should ignore unconfigured `packages.json`', async function () {
Expand All @@ -391,15 +414,17 @@ test('configuration', async function (t) {
streamError: stderr.stream
})

assert.equal(code, 1)
assert.equal(
cleanError(stderr(), 4),
assert.deepEqual(
[code, cleanError(stderr(), 4)],
[
'packages' + sep + 'deep' + sep + 'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `package.json`'
].join('\n')
1,
[
'packages' + sep + 'deep' + sep + 'one.txt',
' error Cannot process file',
' [cause]:',
' Error: Cannot parse file `package.json`'
].join('\n')
]
)
})
})

0 comments on commit 8662388

Please sign in to comment.