-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove references to fsPath (#3306)
- Loading branch information
Showing
8 changed files
with
142 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { readTextDocument } from './readTextDocument.mjs'; | ||
export { isDir, isFile, readTextFile, stat } from './vfs.mjs'; | ||
export { findRepoRoot, findUp, isDir, isFile, normalizeDirUrl, readTextFile, stat, statIfAvailable } from './vfs.mjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { VfsStat } from 'cspell-io'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import { findRepoRoot, findUp, normalizeDirUrl } from './vfs.mjs'; | ||
|
||
const packageRoot = new URL('../../', import.meta.url); | ||
const repoRoot = new URL('../../', packageRoot); | ||
const basename = import.meta.url.split('/').slice(-1).join(''); | ||
|
||
describe('vfs', () => { | ||
test.each` | ||
name | options | expected | ||
${basename} | ${{ cwd: import.meta.url }} | ${import.meta.url} | ||
${'package.json'} | ${{ cwd: import.meta.url }} | ${new URL('package.json', packageRoot).toString()} | ||
${'package.json'} | ${{ cwd: import.meta.url, predicate: () => false }} | ${undefined} | ||
${'.git'} | ${{ cwd: import.meta.url, predicate: (_: URL, stat: VfsStat) => stat.isDirectory() }} | ${new URL('.git', repoRoot).toString()} | ||
${'.git'} | ${{ cwd: import.meta.url }} | ${new URL('.git', repoRoot).toString()} | ||
${'.git'} | ${{ cwd: import.meta.url, root: packageRoot }} | ${undefined} | ||
`('findUp $name, $options', async ({ name, options, expected }) => { | ||
const result = await findUp(name, options); | ||
expect(result?.toString()).toEqual(expected); | ||
}); | ||
|
||
test.each` | ||
url | expected | ||
${packageRoot} | ${packageRoot} | ||
${import.meta.url} | ${new URL('.', import.meta.url)} | ||
${import.meta.url.split('/').slice(0, -1).join('/')} | ${new URL('.', import.meta.url)} | ||
`('normalizeDirUrl $url', async ({ url, expected }) => { | ||
expect((await normalizeDirUrl(url)).toString()).toEqual(expected.toString()); | ||
}); | ||
|
||
test('findRepoRoot', async () => { | ||
expect((await findRepoRoot(import.meta.url))?.toString()).toEqual(repoRoot.toString()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters