Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if (process.argv.length < 4) {
}

const yargs = require('yargs')
// A file can be named with only digits, like `2024`, so each glob is kept as the string that was given
.parserConfiguration({'parse-positional-numbers': false})
.strict()

.usage(
Expand Down
28 changes: 19 additions & 9 deletions test/js/basics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,25 @@ describe('files', () => {
});

// The file names are read by src/cli.ts, so this runs the CLI itself
test.todo('BUG #733: can have a name that is only a number', async () => {
await Bun.write('2024', 'foobar');
const cli = path.join(import.meta.dir, '../../src/cli.ts');
const {stdout, exitCode} = Bun.spawnSync([process.execPath, cli, 'o', 'x', '2024'], {
stdin: 'ignore',
});
expect({out: stdout.toString(), exit: exitCode}).toEqual({out: '2024\n', exit: 0});
expect(await Bun.file('2024').text()).toBe('fxxbar');
});
test.each(['2024', '1e3', '0x10'])(
'can have a name that reads as a number, like %s (#733)',
async (name) => {
await Bun.write(name, 'foobar');
const cli = path.join(import.meta.dir, '../../src/cli.ts');
const {stdout, stderr, exitCode} = Bun.spawnSync(
[process.execPath, cli, 'o', 'x', name],
{
stdin: 'ignore',
}
);
expect({out: stdout.toString(), err: stderr.toString(), exit: exitCode}).toEqual({
out: name + '\n',
err: '',
exit: 0,
});
expect(await Bun.file(name).text()).toBe('fxxbar');
}
);

test('are reported if none are found', async () => {
const result = await rr('o', 'x', {includeGlob: ['nope.file']});
Expand Down
Loading