Files
pnpm/exec/plugin-commands-script-runners/src/restart.ts
2025-08-25 10:02:00 +02:00

49 lines
1.1 KiB
TypeScript

import { types as allTypes } from '@pnpm/config'
import { pick } from 'ramda'
import renderHelp from 'render-help'
import {
handler as run,
IF_PRESENT_OPTION,
IF_PRESENT_OPTION_HELP,
type RunOpts,
} from './run.js'
export function rcOptionsTypes (): Record<string, unknown> {
return {
...pick([
'npm-path',
], allTypes),
}
}
export function cliOptionsTypes (): Record<string, unknown> {
return IF_PRESENT_OPTION
}
export const commandNames = ['restart']
export function help (): string {
return renderHelp({
description: 'Restarts a package. Runs a package\'s "stop", "restart", and "start" scripts, and associated pre- and post- scripts.',
descriptionLists: [
{
title: 'Options',
list: [
IF_PRESENT_OPTION_HELP,
],
},
],
usages: ['pnpm restart [-- <args>...]'],
})
}
export async function handler (
opts: RunOpts,
params: string[]
): Promise<void> {
await run(opts, ['stop', ...params])
await run(opts, ['restart', ...params])
await run(opts, ['start', ...params])
}