Created
August 2, 2023 18:05
-
-
Save andy0130tw/cb627375e146f3d1b6a323854e0c8aa6 to your computer and use it in GitHub Desktop.
SvelteKit will skip generating types if it cannot detect TypeScript environment. Therefore this ad-hoc script is born.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import child_process from 'node:child_process' | |
function run(cmd) { | |
child_process.execSync(cmd, { stdio: 'inherit' }) | |
} | |
;(async () => { | |
let ts_patched = false | |
try { | |
await import('typescript') | |
} catch (err) { | |
console.log('Typescript not detected. Installing...') | |
run('npm i typescript -D') | |
ts_patched = true | |
} | |
console.log('Running sync...') | |
run('npx --yes svelte-kit sync') | |
if (ts_patched) { | |
console.log('Removing typescript...') | |
run('npm r typescript') | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment