-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
051a5d3
commit 599186f
Showing
1 changed file
with
3 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }); | ||
}); |