Skip to content

Commit 8d3c893

Browse files
committed
Run dprint on dtsBundler output
1 parent f20a3ac commit 8d3c893

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

scripts/dtsBundler.mjs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import assert, {
99
fail,
1010
} from "assert";
11+
import cp from "child_process";
1112
import fs from "fs";
1213
import minimist from "minimist";
1314
import path from "path";
@@ -409,5 +410,24 @@ if (publicContents.includes("@internal")) {
409410
console.error("Output includes untrimmed @internal nodes!");
410411
}
411412

412-
fs.writeFileSync(output, publicContents);
413-
fs.writeFileSync(internalOutput, internalContents);
413+
const dprintPath = path.resolve(__dirname, "..", "node_modules", "dprint", "bin.js");
414+
415+
/**
416+
* @param {string} contents
417+
* @returns {string}
418+
*/
419+
function dprint(contents) {
420+
return cp.execFileSync(
421+
process.execPath,
422+
[dprintPath, "fmt", "--stdin", "ts"],
423+
{
424+
stdio: ["pipe", "pipe", "inherit"],
425+
encoding: "utf-8",
426+
input: contents,
427+
maxBuffer: 100 * 1024 * 1024, // 100 MB "ought to be enough for anyone"; https://github.com/nodejs/node/issues/9829
428+
},
429+
);
430+
}
431+
432+
fs.writeFileSync(output, dprint(publicContents));
433+
fs.writeFileSync(internalOutput, dprint(internalContents));

0 commit comments

Comments
 (0)