Skip to content

Commit 1565737

Browse files
authored
feat: new compiler based on tsc (#55)
* use default tsc compiler * read app tsconfig * return error on catch * remove custom compiler * remove commented * remove commented * restore old compiler * fix eslint * fix arg order * TS1196: Catch clause variable cannot have a type annotation. * add flag in compiler * default flag to flase * update compile try script * update ts and node types * update array to readonly array since no mutation * improve security, performance * add tests
1 parent 414edb9 commit 1565737

File tree

10 files changed

+4495
-2972
lines changed

10 files changed

+4495
-2972
lines changed

example/compile.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,34 @@ const path = require('path');
22

33
const { compile } = require('../dist');
44

5-
const out = path.resolve(process.argv.pop());
6-
const source = path.resolve(process.argv.pop());
7-
8-
compile({
9-
tool: 'example',
10-
version: '0.0.1',
11-
when: new Date(),
12-
}, source, out).then(console.log);
5+
// Extract arguments (skip node and script path)
6+
const args = process.argv.slice(2);
7+
8+
if (args.length < 2 || args.length > 3) {
9+
console.error('Usage: node compile.js <sourceDir> <outputFile> [useNativeCompiler]');
10+
process.exit(1);
11+
}
12+
13+
const [sourceArg, outputArg, nativeCompilerArg] = args;
14+
15+
const source = path.resolve(sourceArg);
16+
const out = path.resolve(outputArg);
17+
18+
// Convert string to boolean (treat 'true', '1', etc. as true)
19+
const useNativeCompiler = nativeCompilerArg
20+
? ['true', '1', 'yes'].includes(nativeCompilerArg.toLowerCase())
21+
: false;
22+
23+
compile(
24+
{
25+
tool: 'example',
26+
version: '0.0.1',
27+
when: new Date(),
28+
},
29+
source,
30+
out,
31+
useNativeCompiler,
32+
).then(console.log).catch((err) => {
33+
console.error('Compilation failed:', err);
34+
process.exit(1);
35+
});

0 commit comments

Comments
 (0)