Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dprint.jsonc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// If updating this, also update the config in dtsBundler.mjs.
"indentWidth": 4,
"lineWidth": 1000,
"newLineKind": "auto",
Expand Down Expand Up @@ -56,6 +57,7 @@
"**/_namespaces/**"
],
// Note: if adding new languages, make sure settings.template.json is updated too.
// Also, if updating typescript, update the one in package.json.
"plugins": [
"https://plugins.dprint.dev/typescript-0.90.5.wasm",
"https://plugins.dprint.dev/json-0.19.2.wasm",
Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"!**/.gitattributes"
],
"devDependencies": {
"@dprint/formatter": "^0.3.0",
"@dprint/typescript": "0.90.5",
"@esfx/canceltoken": "^1.0.0",
"@octokit/rest": "^20.1.1",
"@types/chai": "^4.3.16",
Expand Down
25 changes: 13 additions & 12 deletions scripts/dtsBundler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* bundle as namespaces again, even though the project is modules.
*/

import * as dprintFormatter from "@dprint/formatter";
import * as dprintTypeScript from "@dprint/typescript";
import assert, { fail } from "assert";
import cp from "child_process";
import fs from "fs";
import minimist from "minimist";
import path from "path";
Expand Down Expand Up @@ -475,23 +476,23 @@ if (publicContents.includes("@internal")) {
console.error("Output includes untrimmed @internal nodes!");
}

const dprintPath = path.resolve(__dirname, "..", "node_modules", "dprint", "bin.js");
const buffer = fs.readFileSync(dprintTypeScript.getPath());
const formatter = dprintFormatter.createFromBuffer(buffer);
formatter.setConfig({
indentWidth: 4,
lineWidth: 1000,
newLineKind: "auto",
useTabs: false,
}, {
quoteStyle: "preferDouble",
});

/**
* @param {string} contents
* @returns {string}
*/
function dprint(contents) {
const result = cp.execFileSync(
process.execPath,
[dprintPath, "fmt", "--stdin", "ts"],
{
stdio: ["pipe", "pipe", "inherit"],
encoding: "utf-8",
input: contents,
maxBuffer: 100 * 1024 * 1024, // 100 MB "ought to be enough for anyone"; https://github.com/nodejs/node/issues/9829
},
);
const result = formatter.formatText("dummy.d.ts", contents);
return result.replace(/\r\n/g, "\n");
}

Expand Down