Skip to content
Open
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: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ function cli<
throw new Error('Options is required');
}

if ('name' in options && (!options.name || !isValidScriptName(options.name))) {
if ('name' in options && (!options.name || options.name !== options.name.trim())) {
throw new Error(`Invalid script name: ${stringify(options.name)}`);
}

Expand Down
21 changes: 14 additions & 7 deletions tests/specs/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@ describe('cli', () => {
}).toThrow('Invalid script name: ""');
});

test('invalid name format', () => {
test('name with leading space', () => {
expect(() => {
cli({
name: 'a b',
name: ' a',
});
}).toThrow('Invalid script name: "a b"');
}).toThrow('Invalid script name: " a"');
});

test('allowed name format', () => {
cli({
name: 'a.b_',
});
test('name with trailing space', () => {
expect(() => {
cli({
name: 'a ',
});
}).toThrow('Invalid script name: "a "');
});

test('allowed name formats', () => {
cli({ name: 'a.b_' });
cli({ name: 'multiple parent commands' });
});
});

Expand Down