From bf5556c516c7a6bc4d97b3a09243bf8944c57961 Mon Sep 17 00:00:00 2001 From: Eugene Zadorin Date: Mon, 13 Apr 2026 14:44:33 +0300 Subject: [PATCH] Add cook alias for build command --- src/cli.ts | 6 ++++-- test/cli/build.test.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 1139026..4456ca7 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -29,7 +29,9 @@ function lazyCommand(name: string, description: string, loader: () => Promise 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' }); }); @@ -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'))) diff --git a/test/cli/build.test.ts b/test/cli/build.test.ts index 228367a..d13f330 100644 --- a/test/cli/build.test.ts +++ b/test/cli/build.test.ts @@ -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 });