-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle node modules, improve test coverage, track coverage (#9)
* fix: avoid skipping `fileURLToPath` (broke the shit out of fs ops) * test: extract `spawnPromisified` into build util * test: add cases for logger * chore: convert logger to ts * test: cover exit code for logger * fix: package.json "engines" * test: improve types by replacing `string` types with explicit template literals * fix: ignore namespaced specifiers that don't have a file extension * chore: restore node compatibility flag to v22 * test(ci): add node 23.x & disable `fail-fast` * fix: handle node module regardless of whether implementation is found * fix: logger prefix `correct-ts-extensions` → `correct-ts-specifiers` * doc: cite `rewriteRelativeImportExtensions` config option
- Loading branch information
1 parent
dd172de
commit 0224965
Showing
42 changed files
with
772 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { spawn } from 'node:child_process'; | ||
|
||
|
||
export function spawnPromisified(...args: Parameters<typeof spawn>) { | ||
let stderr = ''; | ||
let stdout = ''; | ||
|
||
const child = spawn(...args); | ||
child.stderr!.setEncoding('utf8'); | ||
child.stderr!.on('data', (data) => { stderr += data; }); | ||
child.stdout!.setEncoding('utf8'); | ||
child.stdout!.on('data', (data) => { stdout += data; }); | ||
|
||
return new Promise<{ | ||
code: number | null, | ||
signal: NodeJS.Signals | null, | ||
stderr: string, | ||
stdout: string, | ||
}>((resolve, reject) => { | ||
child.on('close', (code, signal) => { | ||
resolve({ | ||
code, | ||
signal, | ||
stderr, | ||
stdout, | ||
}); | ||
}); | ||
child.on('error', (code, signal) => { | ||
reject({ | ||
code, | ||
signal, | ||
stderr, | ||
stdout, | ||
}); | ||
}); | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 +1,26 @@ | ||
import { access, constants } from 'node:fs/promises'; | ||
|
||
import type { FSAbsolutePath, Specifier } from './index.d.ts'; | ||
import type { | ||
FSAbsolutePath, | ||
Specifier, | ||
} from './index.d.ts'; | ||
import { resolveSpecifier } from './resolve-specifier.ts'; | ||
|
||
|
||
export function fexists( | ||
parentPath: FSAbsolutePath, | ||
specifier: Specifier, | ||
) { | ||
const resolvedSpecifier = resolveSpecifier(parentPath, specifier); | ||
const resolvedSpecifier = resolveSpecifier(parentPath, specifier) as FSAbsolutePath; | ||
|
||
return access( | ||
resolvedSpecifier, | ||
constants.F_OK, | ||
) | ||
.then( | ||
() => true, | ||
() => false, | ||
); | ||
return fexistsResolved(resolvedSpecifier); | ||
}; | ||
|
||
export const fexistsResolved = (resolvedSpecifier: FSAbsolutePath) => access( | ||
resolvedSpecifier, | ||
constants.F_OK, | ||
) | ||
.then( | ||
() => true, | ||
() => 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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import { Avians } from 'animal-features'; | ||
|
||
export class Bird { | ||
constructor(public name: string) {} | ||
constructor( | ||
public name: string, | ||
public eyes?: { | ||
left?: Avians.EyeColour, | ||
right?: Avians.EyeColour, | ||
}, | ||
public feathers?: Avians.FeatherColour | Avians.FeatherColour[], | ||
) {} | ||
} |
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,3 +1,12 @@ | ||
import { Felines } from 'animal-features'; | ||
|
||
export class Cat { | ||
constructor(public name: string) {} | ||
constructor( | ||
public name: string, | ||
public eyes?: { | ||
left?: Felines.EyeColour, | ||
right?: Felines.EyeColour, | ||
}, | ||
public fur?: Felines.FurColour, | ||
) {} | ||
} |
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,3 +1,12 @@ | ||
import { Canines } from 'animal-features'; | ||
|
||
export class Dog { | ||
constructor(public name: string) {} | ||
constructor( | ||
public name: string, | ||
public eyes?: { | ||
left?: Canines.EyeColour, | ||
right?: Canines.EyeColour, | ||
}, | ||
public fur?: Canines.FurColour, | ||
) {} | ||
} |
Oops, something went wrong.