Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel3108 committed Sep 29, 2024
1 parent 051a5d3 commit 599186f
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/cli/commands/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import { execSync } from 'node:child_process';
import { exec } from 'tinyexec';
import { Command } from 'commander';
import { COMMANDS, constructCommand } from 'package-manager-detector';
import * as common from '../common.js';

export const migrate = new Command('migrate')
.description('A CLI for migrating Svelte(Kit) codebases')
.argument('<migration>', 'migration to run')
.configureHelp({
formatHelp() {
// we'll pass the responsibility of presenting the help menu over to `svelte-migrate`
execSync('npx svelte-migrate@latest --help', { stdio: 'inherit' });
execSync('npx --yes svelte-migrate@latest --help', { stdio: 'inherit' });
return '';
}
})
.action(async (migration) => {
const cwd = process.cwd();
const pm = await common.guessPackageManager(cwd);
const { command, args } = constructCommand(COMMANDS[pm].execute, [
'svelte-migrate@latest',
migration
])!;

await exec(command, args, { nodeOptions: { cwd, stdio: 'inherit' } });
.action((migration) => {
execSync(`npx --yes svelte-migrate@latest ${migration}`, { stdio: 'inherit' });
});

0 comments on commit 599186f

Please sign in to comment.