-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't match folders when globbing symbols (#131)
* fix: don't match folders when globbing symbols * refactor: simplify glob
- Loading branch information
Showing
6 changed files
with
48 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { fileExists } from "../src/fs"; | ||
|
||
describe('fs', () => { | ||
describe('fileExists', () => { | ||
it('should return true if the file exists', async () => { | ||
const exists = await fileExists(__filename); | ||
expect(exists).toBe(true); | ||
}); | ||
|
||
it('should return false if the file does not exist', async () => { | ||
const exists = await fileExists('does-not-exist.txt'); | ||
expect(exists).toBe(false); | ||
}); | ||
}); | ||
}) |
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,18 @@ | ||
import { join } from "node:path"; | ||
import { globFiles } from "../src/glob"; | ||
|
||
describe('glob', () => { | ||
describe('globFiles', () => { | ||
it('should return result with directories filtered out', async () => { | ||
const supportDir = join(__dirname, 'support'); | ||
const pattern = join(supportDir, '**', '*.dll'); | ||
const files = await globFiles(pattern); | ||
expect(files).toEqual( | ||
jasmine.arrayContaining([ | ||
join(supportDir, 'bugsplat.dll'), | ||
join(supportDir, 'symsrv', 'bugsplat.dll', '64FB82ED7A000', 'bugsplat.dll'), | ||
]) | ||
); | ||
}); | ||
}); | ||
}); |
Binary file not shown.
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,9 @@ | ||
import { stat } from "node:fs/promises"; | ||
|
||
export async function fileExists(path: string): Promise<boolean> { | ||
try { | ||
return !!(await stat(path)); | ||
} catch { | ||
return false; | ||
} | ||
} |
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,5 @@ | ||
import { glob } from "glob"; | ||
|
||
export async function globFiles(pattern: string): Promise<string[]> { | ||
return glob(pattern, { nodir: true }); | ||
} |