Skip to content

Commit

Permalink
Support tsx to run cli without building
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-y committed Sep 1, 2024
1 parent 1eb0650 commit 4fe7223
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"prepublishOnly": "tsc"
},
"bin": {
"voidc": "./dist/cli.js",
"void": "./dist/cli.js"
"voidc": "./dist/cli/cli.js",
"void": "./dist/cli/cli.js",
"vt": "./src/cli/cli-dev.ts"
},
"keywords": [],
"author": "",
Expand Down
11 changes: 11 additions & 0 deletions src/cli/cli-dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env tsx
import { exec } from "./exec.js";

/**
* NOTE:
* This file is the same as cli.js, but is run with ts-node.
* I've found tsc -w to be buggy when changing git branches,
* so this lets me bypass the compiler.
*/

exec();
4 changes: 4 additions & 0 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
import { exec } from "./exec.js";

exec();
15 changes: 7 additions & 8 deletions src/cli.ts → src/cli/exec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env node
import { stdout } from "process";
import { getConfig } from "./lib/config/index.js";
import { assemble } from "./assembler.js";
import { run } from "./run.js";
import { processSemantics } from "./semantics/index.js";
import { getConfig } from "../lib/config/index.js";
import { assemble } from "../assembler.js";
import { run } from "../run.js";
import { processSemantics } from "../semantics/index.js";
import binaryen from "binaryen";
import { testGc } from "./lib/binaryen-gc/test.js";
import { parseFile, parseModuleFromSrc } from "./parser/index.js";
import { testGc } from "../lib/binaryen-gc/test.js";
import { parseFile, parseModuleFromSrc } from "../parser/index.js";

main().catch(errorHandler);
export const exec = () => main().catch(errorHandler);

async function main() {
const config = getConfig();
Expand Down

0 comments on commit 4fe7223

Please sign in to comment.