rip-lang 3.10.0 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/typecheck.js +12 -1
package/package.json
CHANGED
package/src/typecheck.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// type errors mapped back to Rip source positions.
|
|
12
12
|
|
|
13
13
|
import { Compiler } from './compiler.js';
|
|
14
|
+
import { createRequire } from 'module';
|
|
14
15
|
import { readFileSync, existsSync, readdirSync } from 'fs';
|
|
15
16
|
import { resolve, relative, dirname } from 'path';
|
|
16
17
|
import { buildLineMap } from './sourcemaps.js';
|
|
@@ -210,9 +211,19 @@ const dim = (s) => isColor ? `\x1b[2m${s}\x1b[0m` : s;
|
|
|
210
211
|
const bold = (s) => isColor ? `\x1b[1m${s}\x1b[0m` : s;
|
|
211
212
|
|
|
212
213
|
export async function runCheck(targetDir, opts = {}) {
|
|
213
|
-
const ts = await import('typescript').then(m => m.default || m);
|
|
214
214
|
const rootPath = resolve(targetDir);
|
|
215
215
|
|
|
216
|
+
let ts;
|
|
217
|
+
try {
|
|
218
|
+
const req = createRequire(resolve(rootPath, 'package.json'));
|
|
219
|
+
ts = req('typescript');
|
|
220
|
+
} catch {
|
|
221
|
+
try { ts = await import('typescript').then(m => m.default || m); } catch {
|
|
222
|
+
console.error('TypeScript is required for type checking. Install with: bun add -d typescript');
|
|
223
|
+
return 1;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
216
227
|
if (!existsSync(rootPath)) {
|
|
217
228
|
console.error(red(`Error: directory not found: ${targetDir}`));
|
|
218
229
|
return 1;
|