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
6 changes: 4 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function lazyCommand(name: string, description: string, loader: () => Promise<Re
const mod = await loader();
const command = Object.values(mod).find((v) => v instanceof Command) as Command;

const argv = process.argv.slice(process.argv.indexOf(name) + 1);
const commandNames = [name, ...lazy.aliases()];
const commandIndex = process.argv.findIndex((arg) => commandNames.includes(arg));
const argv = process.argv.slice(commandIndex + 1);
await command.parseAsync(argv, { from: 'user' });
});

Expand Down Expand Up @@ -79,7 +81,7 @@ program
.name('chef')
.version(getChefVersion())
.description('CLI toolkit for building, testing and maintaining Bitrix JS extensions')
.addCommand(lazyCommand('build', 'Build JS extensions for Bitrix', () => import('./commands/build/build-command')))
.addCommand(lazyCommand('build', 'Build JS extensions for Bitrix', () => import('./commands/build/build-command')).alias('cook'))
.addCommand(lazyCommand('lint', 'Run linting for Bitrix JS extensions', () => import('./commands/lint/lint-command')))
.addCommand(lazyCommand('test', 'Run unit and end-to-end tests for extensions', () => import('./commands/test/test-command')))
.addCommand(lazyCommand('create', 'Create a new Bitrix JS extension scaffold', () => import('./commands/create/create-command')))
Expand Down
10 changes: 10 additions & 0 deletions test/cli/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ describe('chef build', () => {

// region: basic commands

it('should build an extension by name using cook alias', async () => {
const extensionDist = path.join(tmpRepo, 'ui/install/js/ui/buttons/dist');
fs.rmSync(extensionDist, { recursive: true, force: true });

const { exitCode } = await runChef(['cook', 'ui.buttons'], { cwd: tmpRepo });

assert.equal(exitCode, 0);
assert.isTrue(fs.existsSync(path.join(extensionDist, 'buttons.bundle.js')));
});

it('should build an extension by name', async () => {
const extensionDist = path.join(tmpRepo, 'ui/install/js/ui/buttons/dist');
fs.rmSync(extensionDist, { recursive: true, force: true });
Expand Down