diff --git a/package.json b/package.json index 3c81701..c7a0c85 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "types": "typescript/index.d.ts", "type": "module", "scripts": { - "postinstall": "tsc", + "postinstall": "node scripts/postinstall.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ diff --git a/scripts/postinstall.js b/scripts/postinstall.js new file mode 100644 index 0000000..6799d0b --- /dev/null +++ b/scripts/postinstall.js @@ -0,0 +1,10 @@ +import { execSync } from 'child_process'; + +try { + // Check if TypeScript is installed + execSync('tsc --version', { stdio: 'ignore' }); + console.log('TypeScript detected, running tsc...'); + execSync('tsc', { stdio: 'inherit' }); +} catch (error) { + console.warn('TypeScript is not installed. Skipping compilation.'); +}