Open History to see the last commit
1import { resolve } from 'node:path'
2
3import type { Environment, Options } from '../types.js'
4
5const lockFiles = ['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml']
6
7export async function rimrafNodeModules(
8 environment: Environment,
9 options: Options,
10) {
11 environment.startStep({
12 id: 'special-steps',
13 type: 'command',
14 message: 'Removing node_modules...',
15 })
16
17 await environment.rimraf(resolve(options.targetDir, 'node_modules'))
18
19 for (const lockFile of lockFiles) {
20 const lockFilePath = resolve(options.targetDir, lockFile)
21 if (environment.exists(lockFilePath)) {
22 await environment.deleteFile(lockFilePath)
23 }
24 }
25}