Open History to see the last commit
1import { rimrafNodeModules } from './rimraf-node-modules.js'
2import { postInitScript } from './post-init-script.js'
3
4import type { Environment, Options } from '../types.js'
5
6const specialStepsLookup: Record<
7 string,
8 (environment: Environment, options: Options) => Promise<void>
9> = {
10 'rimraf-node-modules': rimrafNodeModules,
11 'post-init-script': postInitScript,
12}
13
14export async function runSpecialSteps(
15 environment: Environment,
16 options: Options,
17 specialSteps: Array<string>,
18) {
19 if (specialSteps.length) {
20 environment.startStep({
21 id: 'special-steps',
22 type: 'command',
23 message: 'Running special steps...',
24 })
25
26 for (const step of specialSteps) {
27 const stepFunction = specialStepsLookup[step]
28 /* eslint-disable @typescript-eslint/no-unnecessary-condition */
29 if (stepFunction) {
30 await stepFunction(environment, options)
31 } else {
32 environment.error(`Special step ${step} not found`)
33 }
34 }
35
36 environment.finishStep('special-steps', 'Special steps complete')
37 }
38}