Skip to content

Commit

Permalink
Simplify regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
wojpawlik committed Sep 6, 2023
1 parent e5170c2 commit f330ef1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/emit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Diagnostic, MemoryEmitResultFile, Project } from "./deps.deno.ts";
import { chmod } from "node:fs/promises";
import type { Diagnostic, MemoryEmitResultFile, Project } from "./deps.deno.ts";

const anyShebang = /^#![^\n]*\n/;
const denoShebang = /^#!\/usr\/bin\/env -S deno run\b[^\n]*\n/;
const nodeShebang = "#!/usr/bin/env node\n";
const anyShebang = /^#!.*/;
const denoShebang = /^#!\/usr\/bin\/env -S deno run\b.*/;
const nodeShebang = "#!/usr/bin/env node";

function transpileShebang(file: MemoryEmitResultFile) {
file.text = file.filePath.endsWith(".js")
? file.text.replace(denoShebang, nodeShebang)
: file.text.replace(anyShebang, "\n");
: file.text.replace(anyShebang, "");
}

async function markExecutableIfNeeded(file: MemoryEmitResultFile) {
Expand Down

0 comments on commit f330ef1

Please sign in to comment.