Skip to content

Commit

Permalink
new API: nullDevice()
Browse files Browse the repository at this point in the history
  • Loading branch information
cscheid committed Jan 9, 2025
1 parent 4bf8a6c commit de6f206
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { execProcess } from "./process.ts";
import { architectureToolsPath } from "./resources.ts";
import { TempContext } from "./temp-types.ts";
import { createTempContext } from "./temp.ts";
import { kQuartoVersion } from "../config/constants.ts";
import { nullDevice } from "./platform.ts";

type ESBuildAnalysisImport = {
path: string;
Expand Down Expand Up @@ -46,13 +46,20 @@ export async function esbuildAnalyze(
[
"--analyze=verbose",
`--metafile=${tempName}`,
"--outfile=/dev/null",
`--outfile=${nullDevice()}`,
input,
],
"",
workingDir,
);
return JSON.parse(Deno.readTextFileSync(tempName)) as ESBuildAnalysis;
const result = JSON.parse(
Deno.readTextFileSync(tempName),
) as ESBuildAnalysis;
assert(Object.entries(result.outputs).length === 1);
result.outputs = {
"<output>": Object.values(result.outputs)[0],
};
return result;
} finally {
if (mustCleanup) {
tempContext.cleanup();
Expand Down
4 changes: 4 additions & 0 deletions src/core/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ export function isInteractiveSession() {
export function isGithubAction() {
return Deno.env.get("GITHUB_ACTIONS") === "true";
}

export function nullDevice() {
return isWindows ? "NUL" : "/dev/null";
}

0 comments on commit de6f206

Please sign in to comment.