Skip to content

Commit 2a31b0b

Browse files
committed
fix: misc
1 parent 9873577 commit 2a31b0b

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"build:watch": "tsc --watch --preserveWatchOutput",
1414
"cleaner": "ts-cleaner --dist lib --watch",
1515
"test": "jest",
16+
"test:full": "COMPILE_EXAMPLES=1 jest",
1617
"test:watch": "jest --watch",
1718
"test:coverage": "jest --config jest.coverage.js",
1819
"test:coverage:watch": "jest --watchAll --config jest.coverage.js",

src/args.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export class Args<TArgTypes extends DefaultArgTypes = DefaultArgTypes> {
3737
// We store both a tree and a list so that we can iterate all values efficiently
3838
public arguments: PrefixTree<InternalArgument> = new PrefixTree()
3939
public argumentsList: InternalArgument[] = []
40-
40+
4141
public commands: PrefixTree<InternalCommand> = new PrefixTree()
4242
public commandsList: InternalCommand[] = []
43-
43+
4444
public resolvers: Resolver[] = []
4545
public builtins: Builtin[] = []
4646
public footerLines: string[] = []

src/builder/builtin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export abstract class Builtin {
2222
return this
2323
}
2424

25-
abstract run (parser: Args<unknown>, flags: Record<string, string[]>, positionals: string[], trigger: string): Promise<void>
25+
abstract run (parser: Args<{}>, flags: Record<string, string[]>, positionals: string[], trigger: string): Promise<void>
2626

2727
helpInfo (): string {
2828
return `${this.commandTriggers.map(cmd => `${cmd} <...args>`).join(', ')} | ${this.argumentTriggers.map(arg => `--${arg}`).join(', ')}`

src/builder/default-builtins.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Help extends Builtin {
1010
this.onCommand('help')
1111
}
1212

13-
async run (parser: Args<unknown>): Promise<void> {
13+
async run (parser: Args<{}>): Promise<void> {
1414
console.log(parser.help())
1515
}
1616
}
@@ -22,7 +22,7 @@ export class Version extends Builtin {
2222
this.onArgument('version')
2323
}
2424

25-
async run (parser: Args<unknown>): Promise<void> {
25+
async run (parser: Args<{}>): Promise<void> {
2626
console.log(`${parser.opts.programName} (${parser.opts.programVersion})`)
2727
}
2828
}
@@ -34,7 +34,7 @@ export class ShellCompletion extends Builtin {
3434
this.onCommand('completion')
3535
}
3636

37-
async run (parser: Args<unknown>, __: Record<string, string[]>, positionals: string[]): Promise<void> {
37+
async run (parser: Args<{}>, __: Record<string, string[]>, positionals: string[]): Promise<void> {
3838
positionals = positionals.slice(1)
3939
const [shell] = positionals
4040

src/internal/parse/coerce.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ export async function coerce (
494494
type: 'builtin',
495495
command: foundBuiltin,
496496
trigger
497-
}
497+
},
498+
rest: undefined
498499
})
499500
}
500501

test/ensure-examples-compile.test.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,37 @@ import fsp from 'fs/promises'
22
import path from 'path'
33
import { execSync } from 'child_process'
44

5+
interface ExecError {
6+
status: number
7+
signal: null
8+
output: string[]
9+
pid: number
10+
stdout: string
11+
stderr: string
12+
}
13+
514
describe('Example compilation', () => {
6-
it('can compile the examples', async () => {
7-
if (!process.env.GITHUB_ACTIONS) {
8-
return
9-
}
15+
if (!process.env.COMPILE_EXAMPLES) {
16+
it.skip('can compile the examples', () => {})
17+
return
18+
}
1019

20+
it('can compile the examples', async () => {
1121
const dir = path.join(__dirname, '..', 'examples')
1222
const examples = await fsp.readdir(dir)
1323

1424
for (const example of examples) {
1525
console.time(example)
16-
execSync(`npm run build --prefix ${path.join(dir, example)}`)
26+
27+
try {
28+
execSync(`npm run build --prefix ${path.join(dir, example)}`, {
29+
encoding: 'utf-8'
30+
})
31+
} catch (_err) {
32+
const err = _err as ExecError
33+
console.error('Example', example, 'failed to compile:', err.stdout)
34+
}
35+
1736
console.timeEnd(example)
1837
}
1938
})

0 commit comments

Comments
 (0)