Skip to content

Commit

Permalink
feat(abi-ts): move logs to debug (#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Oct 11, 2023
1 parent e241c05 commit ca32917
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-falcons-fail.md
@@ -0,0 +1,5 @@
---
"@latticexyz/abi-ts": minor
---

Moves log output behind a debug flag. You can enable logging with `DEBUG=abi-ts` environment variable.
2 changes: 2 additions & 0 deletions packages/abi-ts/package.json
Expand Up @@ -32,11 +32,13 @@
},
"dependencies": {
"chalk": "^5.3.0",
"debug": "^4.3.4",
"execa": "^7.0.0",
"glob": "^8.0.3",
"yargs": "^17.7.1"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/glob": "^7.2.0",
"@types/node": "^18.15.11",
"@types/yargs": "^17.0.10",
Expand Down
3 changes: 3 additions & 0 deletions packages/abi-ts/src/debug.ts
@@ -0,0 +1,3 @@
import createDebug from "debug";

export const debug = createDebug("abi-ts");
6 changes: 3 additions & 3 deletions packages/abi-ts/src/index.ts
@@ -1,7 +1,7 @@
import type { CommandModule } from "yargs";
import { readFileSync, writeFileSync } from "fs";
import glob from "glob";
import path from "path";
import { debug } from "./debug";

type Options = {
input: string;
Expand Down Expand Up @@ -34,14 +34,14 @@ const commandModule: CommandModule<Options, Options> = {
for (const jsonFilename of files) {
const json = readFileSync(jsonFilename, "utf8").trim();
if (json === "[]") {
console.log("Skipping empty ABI file", jsonFilename);
debug("Skipping empty ABI file", jsonFilename);
continue;
}

const ts = `declare const abi: ${json}; export default abi;\n`;
const tsFilename = `${jsonFilename}.d.ts`;

console.log("Writing", tsFilename);
debug("Writing", tsFilename);
writeFileSync(tsFilename, ts);
}

Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit ca32917

Please sign in to comment.