Skip to content

Commit e6f2102

Browse files
committed
Increase maxBuffer for execFileSync
1 parent 3babc44 commit e6f2102

File tree

5 files changed

+30
-21
lines changed

5 files changed

+30
-21
lines changed

.github/workflows/eslint-plugin-diff.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v3
9-
with:
10-
fetch-depth: 0
119
- name: Install modules
1210
run: yarn
11+
- name: Link the plugin
12+
run: |
13+
yarn link
14+
yarn link "eslint-plugin-diff"
15+
- name: Fetch the base branch
16+
run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
1317
- name: Run ESLint on your changes only
1418
env:
15-
ESLINT_PLUGIN_DIFF_COMMIT: origin/${{ github.event.pull_request.base.ref }}
16-
run: |
17-
echo "ESLINT_PLUGIN_DIFF_COMMIT: $ESLINT_PLUGIN_DIFF_COMMIT"
18-
git diff $ESLINT_PLUGIN_DIFF_COMMIT
19-
git --version
20-
node_modules/.bin/eslint --ext .js,.jsx,.ts,.tsx .
19+
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }}
20+
run: npx --no-install eslint --ext .js,.jsx,.ts,.tsx .

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,23 @@ To lint all the changes of a PR, you only have to set
5454

5555
### For GitHub Actions
5656

57-
```sh
58-
export ESLINT_PLUGIN_DIFF_COMMIT="origin/$GITHUB_BASE_REF";
59-
npx --no-install eslint --ext .js,.ts,.tsx .
57+
```yml
58+
name: Run ESLint on your changes only
59+
on:
60+
pull_request:
61+
jobs:
62+
build:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v3
66+
- name: Install modules
67+
run: npm install
68+
- name: Fetch the base branch
69+
run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
70+
- name: Run ESLint on your changes only
71+
env:
72+
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }}
73+
run: npx --no-install eslint --ext .js,.jsx,.ts,.tsx .
6074
```
6175
6276
### For BitBucket Pipelines

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"@typescript-eslint/parser": "^5.27.0",
5757
"eslint": "^8.17.0",
5858
"eslint-config-prettier": "^8.5.0",
59-
"eslint-plugin-diff": "^2.0.0",
6059
"eslint-plugin-import": "^2.26.0",
6160
"eslint-plugin-promise": "^6.0.0",
6261
"husky": "^8.0.1",

src/git.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const getDiffForFile = (filePath: string, staged = false): string => {
2222
[]
2323
);
2424

25-
return child_process.execFileSync(COMMAND, args).toString();
25+
return child_process.execFileSync(COMMAND, args, options).toString();
2626
};
2727

2828
const getDiffFileList = (staged = false): string[] => {
@@ -42,7 +42,7 @@ const getDiffFileList = (staged = false): string[] => {
4242
);
4343

4444
return child_process
45-
.execFileSync(COMMAND, args)
45+
.execFileSync(COMMAND, args, options)
4646
.toString()
4747
.trim()
4848
.split("\n")
@@ -62,14 +62,15 @@ const hasCleanIndex = (filePath: string): boolean => {
6262

6363
let result = true;
6464
try {
65-
child_process.execFileSync(COMMAND, args).toString();
65+
child_process.execFileSync(COMMAND, args, options).toString();
6666
} catch (err: unknown) {
6767
result = false;
6868
}
6969

7070
return result;
7171
};
7272

73+
const options = { maxBuffer: 1024 * 1024 * 100 };
7374
const getUntrackedFileList = (staged = false): string[] => {
7475
if (staged) {
7576
return [];
@@ -78,7 +79,7 @@ const getUntrackedFileList = (staged = false): string[] => {
7879
const args = ["ls-files", "--exclude-standard", "--others"];
7980

8081
const untrackedFileListCache = child_process
81-
.execFileSync(COMMAND, args)
82+
.execFileSync(COMMAND, args, options)
8283
.toString()
8384
.trim()
8485
.split("\n")

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,11 +1891,6 @@ eslint-module-utils@^2.7.3:
18911891
debug "^3.2.7"
18921892
find-up "^2.1.0"
18931893

1894-
eslint-plugin-diff@^2.0.0:
1895-
version "2.0.0"
1896-
resolved "https://registry.yarnpkg.com/eslint-plugin-diff/-/eslint-plugin-diff-2.0.0.tgz#d714ead965e04aef1f7e4f87eac292b84a5599bc"
1897-
integrity sha512-sSKwFOahooDy9ld60RJ4U696+FNP4bVrHaYsLFtJJXxkhujA+kAnxtmLF6PaUlBuFcTCtsYwyN13zkZKT8J1Uw==
1898-
18991894
eslint-plugin-import@^2.26.0:
19001895
version "2.26.0"
19011896
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b"

0 commit comments

Comments
 (0)