Skip to content

Instantly share code, notes, and snippets.

@WanLinLin
Created July 25, 2024 03:58
Show Gist options
  • Save WanLinLin/fb44c17fd54a40fcf4063c5c3e708199 to your computer and use it in GitHub Desktop.
Save WanLinLin/fb44c17fd54a40fcf4063c5c3e708199 to your computer and use it in GitHub Desktop.
tsc files
import { spawnSync } from 'child_process'
import { writeFileSync, rmSync } from 'fs'
const tempTsConfig = './lint-staged-tsconfig.json'
const main = () => {
const files = process.argv.slice(2)
writeFileSync(
tempTsConfig,
JSON.stringify({
extends: './tsconfig.json',
include: files,
})
)
const { status } = spawnSync(
'npx',
['tsc', `-p`, tempTsConfig, '--noEmit', '--tsBuildInfoFile', 'false'],
{
stdio: 'inherit',
}
)
rmSync(tempTsConfig)
process.exit(status)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment