Skip to content

Commit

Permalink
Consistently avoid Deno namespace in cli.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
wojpawlik committed Aug 11, 2023
1 parent 8d125fa commit d5ad0db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
shell: bash

runs-on: ${{ matrix.os }}
timeout-minutes: 1
steps:
- uses: actions/checkout@v3
- run: npm install --ignore-scripts
Expand Down
16 changes: 9 additions & 7 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
#!/usr/bin/env -S deno run --no-prompt --allow-read=. --allow-write=lib/
import { existsSync } from "node:fs";
import * as process from "node:process";
import { ts } from "./deps.deno.ts";
import { getHelpText } from "./help.ts";
import { getVersion, initializeProject } from "./init.ts";
import { Context, deno2node, emit } from "./mod.ts";

const { options, fileNames, errors } = ts.parseCommandLine(Deno.args);
const args = process.argv.slice(2);
const { options, fileNames, errors } = ts.parseCommandLine(args);
const tsConfigFilePath = options.project ?? ts.findConfigFile(".", existsSync);

if (errors.length) {
for (const error of errors) {
console.error(error.messageText);
}
Deno.exit(2);
process.exit(2);
}

if (options.help) {
console.log(getHelpText(await getVersion()));
Deno.exit(0);
process.exit(0);
}

if (options.version) {
console.log("deno2node", await getVersion());
console.log("typescript", ts.version);
Deno.exit(0);
process.exit(0);
}

if (options.init) {
await initializeProject();
Deno.exit(0);
process.exit(0);
}

const ctx = new Context({
Expand All @@ -44,7 +46,7 @@ if (fileNames.length) {
ctx.project.addSourceFilesFromTsConfig(tsConfigFilePath);
} else {
console.error("Specify entry points.");
Deno.exit(2);
process.exit(2);
}
ctx.project.resolveSourceFileDependencies();
console.timeEnd("Loading source files");
Expand All @@ -58,5 +60,5 @@ if (diagnostics.length !== 0) {
console.info(ctx.project.formatDiagnosticsWithColorAndContext(diagnostics));
console.info("TypeScript", ts.version);
console.info(`Found ${diagnostics.length} errors.`);
Deno.exit(1);
process.exit(1);
}

0 comments on commit d5ad0db

Please sign in to comment.