Skip to content

Commit

Permalink
Avoid Deno namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
wojpawlik committed Sep 8, 2023
1 parent c4a503b commit 938422f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
defaults:
run:
shell: bash

runs-on: ${{ matrix.os }}
timeout-minutes: 1
steps:
- uses: actions/checkout@v3
- run: npm install --ignore-scripts
Expand Down
4 changes: 2 additions & 2 deletions src/emit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Diagnostic, MemoryEmitResultFile, Project } from "./deps.deno.ts";
import { chmod } from "node:fs/promises";

const anyShebang = /^#![^\n]*\n/;
const denoShebang = /^#!\/usr\/bin\/env -S deno run\b[^\n]*\n/;
Expand All @@ -11,9 +12,8 @@ function transpileShebang(file: MemoryEmitResultFile) {
}

async function markExecutableIfNeeded(file: MemoryEmitResultFile) {
if (Deno.build.os === "windows") return;
if (!file.text.startsWith(nodeShebang)) return;
await Deno.chmod(file.filePath, 0o755);
await chmod(file.filePath, 0o755);
}

/**
Expand Down
8 changes: 2 additions & 6 deletions src/shim.node.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// Node-only, see https://github.com/fromdeno/deno2node#shimming
import { chmod, readFile } from "node:fs/promises";
import process from "node:process";
import { readFile } from "node:fs/promises";
import * as process from "node:process";
import { isatty } from "node:tty";

const os = process.platform === "win32" ? "windows" : process.platform;

export const Deno = {
// please keep sorted
args: process.argv.slice(2),
build: { os },
chmod,
exit: process.exit,
isatty,
noColor: process.env.NO_COLOR !== undefined,
Expand Down

0 comments on commit 938422f

Please sign in to comment.