We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a38ce5 commit b6bf67fCopy full SHA for b6bf67f
bin/destroy.ts
@@ -1,8 +1,10 @@
1
#!/usr/bin/env node
2
3
+import * as fs from 'fs'
4
import * as path from 'path'
5
import { fileURLToPath } from 'url'
6
import { spawnSync } from 'child_process'
7
+import { createRequire } from 'node:module';
8
9
import parseArgs from 'minimist'
10
@@ -39,6 +41,9 @@ export async function main(args: string[]): Promise<void> {
39
41
stdio: [process.stdin, process.stdout, process.stderr],
40
42
env: process.env,
43
})
44
+
45
+ fs.rmSync(artifactPath, { recursive: true, force: true })
46
47
}
48
49
if (process.argv[1] === fileURLToPath(import.meta.url)) {
tests/bin.destroy.test.ts
@@ -45,7 +45,8 @@ describe('bin/destroy.ts', () => {
const argv = ['node', 'destroy']
await destroy.main(argv)
-
+ expect(fs.existsSync(buildDir)).toBe(false)
50
fs.rmSync(tmpDir, { recursive: true })
51
52
let spawnSyncMock = <any>spawnSync
@@ -78,7 +79,7 @@ describe('bin/destroy.ts', () => {
78
79
const argv = ['node', 'destroy', tmpDir]
80
81
- fs.rmSync(tmpDir, { recursive: true })
82
+ expect(fs.existsSync(tmpDir)).toBe(false)
83
84
85
const args = spawnSyncMock.mock.calls[0]
@@ -94,4 +95,16 @@ describe('bin/destroy.ts', () => {
94
95
])
96
)
97
98
99
+ it('main (no args or build)', async () => {
100
+ const tmpDir = getTempDir()
101
+ const spy = vi.spyOn(process, 'cwd')
102
+ spy.mockReturnValue(tmpDir)
103
104
+ const argv = ['node', 'destroy']
105
+ await destroy.main(argv)
106
107
+ fs.rmSync(tmpDir, { recursive: true })
108
+ })
109
110
0 commit comments