Skip to content

Commit

Permalink
fix: ensure all eslint logging is shown (#121)
Browse files Browse the repository at this point in the history
* Log eslint vis console.log

* log each line

* Try event logging
  • Loading branch information
grant0417 committed Mar 22, 2024
1 parent 8cdbba8 commit 3ca1a38
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 215 deletions.
410 changes: 205 additions & 205 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.

4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "push-to-fig-autocomplete-action",
"version": "2.0.0",
"version": "2.0.1",
"private": true,
"description": "Action to automatically open a new PR to the withfig/autocomplete repo",
"main": "lib/main.js",
Expand Down
6 changes: 2 additions & 4 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,12 +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,
);
core.info(`Output: ${logs.stdout}`);
core.info(`Errors: ${logs.stderr}`);
core.endGroup();
}

Expand Down
17 changes: 17 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ 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 3ca1a38

Please sign in to comment.