Skip to content

Commit

Permalink
Try event logging
Browse files Browse the repository at this point in the history
  • Loading branch information
grant0417 committed Mar 7, 2024
1 parent b8a9496 commit e90396f
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 218 deletions.
412 changes: 205 additions & 207 deletions dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions src/lint-format.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from "node:path";
import * as core from "@actions/core";
import { execAsync } from "./utils";
import { execAsync, execAsyncWithLogs } from "./utils";
import { writeFile } from "node:fs/promises";

// TODO: find a way to have shared configs for all autocomplete tools)
Expand All @@ -17,16 +17,10 @@ async function runEslintOnPath(p: string, cwd: string) {
},
);
await execAsync("npm i @fig/eslint-config-autocomplete@latest eslint@8", cwd);
const logs = await execAsync(
await execAsyncWithLogs(
`npx eslint@8 --no-ignore --no-eslintrc --config .tmp-eslintrc --debug --fix ${p}`,
cwd,
);
for (const line of logs.stdout.split("\n")) {
core.info(line);
}
for (const line of logs.stderr.split("\n")) {
core.info(line);
}
core.endGroup();
}

Expand Down
18 changes: 18 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ export async function execAsync(
});
}

export async function execAsyncWithLogs(
command: string,
cwd?: string,
): Promise<void> {
return new Promise((resolve) => {
const child = exec(command, { cwd }, () => {
resolve();
});
child.stdout?.on("data", function (data) {
core.info(data);
});

child.stderr?.on("data", function (data) {
core.info(data);
});
});
}

export async function mkdirIfNotExists(
...args: Parameters<typeof mkdir>
): Promise<void> {
Expand Down

0 comments on commit e90396f

Please sign in to comment.