-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7af035
commit fe77f8e
Showing
3 changed files
with
50 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env zx | ||
import { $, argv } from "zx"; | ||
|
||
// List of valid commands | ||
const VALID_COMMANDS = ["codegen"]; | ||
|
||
async function getNpxCompatibleCommand() { | ||
const commands = ["npx", "pnpx", "bunx"]; | ||
|
||
for (const cmd of commands) { | ||
try { | ||
await $`command -v ${cmd}`; | ||
return cmd; // Return early if the command is found | ||
} catch { | ||
continue; // Continue to the next iteration if the command is not found | ||
} | ||
} | ||
} | ||
|
||
async function run() { | ||
const COMMAND = argv._[1]; | ||
|
||
const NPX_COMMAND = await getNpxCompatibleCommand(); | ||
|
||
switch (COMMAND) { | ||
case "codegen": | ||
{ | ||
const { src, out, flatten, exclude } = argv; | ||
|
||
await $`${NPX_COMMAND} tsx ./scripts/codegen.ts --src ${src} --out ${out} --exclude ${exclude} ${ | ||
flatten ? "--flatten" : "" | ||
}`; | ||
} | ||
break; | ||
default: | ||
await $`echo unknown command received: '${COMMAND}'`; | ||
await $`echo valid commands:`; | ||
|
||
// eslint-disable-next-line no-undef | ||
VALID_COMMANDS.forEach((cmd) => console.log(` * ${cmd}`)); | ||
} | ||
} | ||
|
||
run().catch((e) => { | ||
// eslint-disable-next-line no-undef | ||
console.error(e); | ||
// eslint-disable-next-line no-undef | ||
process.exit(1); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters