forked from zwave-js/node-zwave-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add precommit hook to format files (zwave-js#6205)
- Loading branch information
Showing
7 changed files
with
276 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"*.{js,ts,json,md}": "node maintenance/fmt-staged.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const path = require("path"); | ||
|
||
// Dprint parallelizes formatting and is generally fast enough to run on the whole repo | ||
// despite lint-staged telling us which files have changed. | ||
const repoRoot = path.join(__dirname, ".."); | ||
require("child_process").spawnSync("yarn", ["fmt"], { | ||
cwd: repoRoot, | ||
}); | ||
|
||
// If it ever becomes slow, the approach below works: | ||
|
||
// const fs = require("fs"); | ||
// const { formatWithDprint } = require("@zwave-js/fmt"); | ||
|
||
// const files = process.argv.slice(2); | ||
|
||
// for (const file of files) { | ||
// // Skip package.json and similar | ||
// if (path.basename(file) === "package.json") continue; | ||
// if (path.basename(file) === "package-lock.json") continue; | ||
|
||
// console.log(`Formatting ${file}...`); | ||
// const content = fs.readFileSync(file, "utf8"); | ||
// const formatted = formatWithDprint(repoRoot, file, content); | ||
// fs.writeFileSync(file, formatted, "utf8"); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.