From d5ad0db488829fe44b58b6da76a0bfd237306f27 Mon Sep 17 00:00:00 2001 From: Wojciech Pawlik Date: Fri, 11 Aug 2023 20:35:17 +0200 Subject: [PATCH] Consistently avoid `Deno` namespace in `cli.ts` --- .github/workflows/ci.yml | 1 + src/cli.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1cc42f3..bfd0827 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: shell: bash runs-on: ${{ matrix.os }} + timeout-minutes: 1 steps: - uses: actions/checkout@v3 - run: npm install --ignore-scripts diff --git a/src/cli.ts b/src/cli.ts index dc2a67c..9f24d65 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -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({ @@ -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"); @@ -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); }