diff --git a/src/command/update.ts b/src/command/update.ts new file mode 100644 index 0000000..a11487a --- /dev/null +++ b/src/command/update.ts @@ -0,0 +1,16 @@ +import { program, Command } from '@/program.ts'; +import { execSync } from 'node:child_process'; + +const update = new Command('update') + .option('-g --global', 'update global') + .description('update cli') + .action((opts) => { + try { + const cmd = opts.global ? 'npm install -g @kevisual/envision-cli' : 'npm install -D @kevisual/envision-cli'; + execSync(cmd, { stdio: 'inherit', encoding: 'utf-8' }); + } catch (error) { + console.error('Error updating CLI:', error); + } + }); + +program.addCommand(update); diff --git a/src/index.ts b/src/index.ts index d1da22b..1dc1723 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,8 @@ import './command/npm.ts'; import './command/publish.ts'; import './command/init.ts'; import './command/proxy.ts'; +import './command/update.ts'; + import './command/sync/sync.ts'; import './command/app/index.ts';