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 0d7aae4 commit 237f2f8Copy full SHA for 237f2f8
bin/destroy.ts
@@ -1,7 +1,8 @@
1
#!/usr/bin/env node
2
3
import * as path from 'path'
4
-import { fileURLToPath } from 'url'
+import { realpathSync } from 'fs'
5
+import { pathToFileURL } from 'url'
6
import { spawnSync } from 'child_process'
7
import { createRequire } from 'node:module'
8
@@ -45,6 +46,12 @@ export async function main(args: string[]): Promise<void> {
45
46
}
47
48
-if (process.argv[1] === fileURLToPath(import.meta.url)) {
49
+function wasCalledAsScript(): boolean {
50
+ const realPath = realpathSync(process.argv[1])
51
+ const realPathAsUrl = pathToFileURL(realPath).href
52
+ return import.meta.url === realPathAsUrl
53
+}
54
+
55
+if (wasCalledAsScript()) {
56
main(process.argv)
57
0 commit comments