Skip to content

Commit d3e6e90

Browse files
committed
feat: add exitHook
1 parent f23d8ad commit d3e6e90

File tree

7 files changed

+29
-24
lines changed

7 files changed

+29
-24
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"devDependencies": {
5454
"@antfu/eslint-config": "^0.16.1",
5555
"@antfu/ni": "^0.21.3",
56+
"@types/async-exit-hook": "^2.0.0",
5657
"@types/fs-extra": "^9.0.13",
5758
"@types/minimist": "^1.2.2",
5859
"@types/mustache": "^4.2.2",
@@ -68,11 +69,11 @@
6869
"vitest": "^0.31.1"
6970
},
7071
"dependencies": {
72+
"async-exit-hook": "^2.0.1",
7173
"axios": "^0.26.1",
7274
"chalk": "^5.2.0",
7375
"fs-extra": "^10.1.0",
7476
"globby": "^13.1.4",
75-
"haxx": "^0.0.4",
7677
"kleur": "^4.1.5",
7778
"kleur-template": "^0.0.3",
7879
"minimist": "^1.2.8",

playground/bun.lockb

294 Bytes
Binary file not shown.

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"devDependencies": {
66
"@antfu/ni": "^0.21.3",
77
"bun-types": "^0.5.0",
8-
"haxx": "^0.6.0"
8+
"haxx": "0.6.1"
99
},
1010
"scripts": {
1111
"start": "haxx scripts/index.ts"

pnpm-lock.yaml

Lines changed: 15 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/globals.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ declare global {
1818
const template: typeof _.template
1919
const style: typeof _.style
2020
const resguard: typeof _.resguard
21+
const exitHook: typeof _.exitHook
2122
}

src/haxx.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ async function importPath(filepath: string, origin = filepath) {
115115
origin,
116116
)
117117
}
118+
119+
if (ext === '.ts') {
120+
const tmpFilename = `${path.basename(filepath)}-${Math.random().toString(36).slice(2)}.mjs`
121+
const tmpFilepath = path.join(path.dirname(filepath), tmpFilename)
122+
await $`tsc --outFile ${tmpFilepath} ${filepath}`
123+
// await importPath(tmpFilepath, origin)
124+
return
125+
}
126+
118127
const __filename = path.resolve(origin)
119128
const __dirname = path.dirname(__filename)
120129
const require = createRequire(origin)

src/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export { default as kleur } from 'kleur'
66
export { default as fs } from 'fs-extra'
77
export { default as YAML } from 'yaml'
88
export { resguard } from 'resguard'
9-
9+
export { default as exitHook } from 'async-exit-hook'
1010
export * as glob from 'globby'
1111
export { style } from 'kleur-template'
1212
export { template } from './template.js'

0 commit comments

Comments
 (0)