Skip to content

Commit

Permalink
Increase maxBuffer for execFileSync
Browse files Browse the repository at this point in the history
  • Loading branch information
paleite committed Jul 29, 2022
1 parent 3babc44 commit e6f2102
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/eslint-plugin-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install modules
run: yarn
- name: Link the plugin
run: |
yarn link
yarn link "eslint-plugin-diff"
- name: Fetch the base branch
run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
- name: Run ESLint on your changes only
env:
ESLINT_PLUGIN_DIFF_COMMIT: origin/${{ github.event.pull_request.base.ref }}
run: |
echo "ESLINT_PLUGIN_DIFF_COMMIT: $ESLINT_PLUGIN_DIFF_COMMIT"
git diff $ESLINT_PLUGIN_DIFF_COMMIT
git --version
node_modules/.bin/eslint --ext .js,.jsx,.ts,.tsx .
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }}
run: npx --no-install eslint --ext .js,.jsx,.ts,.tsx .
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,23 @@ To lint all the changes of a PR, you only have to set

### For GitHub Actions

```sh
export ESLINT_PLUGIN_DIFF_COMMIT="origin/$GITHUB_BASE_REF";
npx --no-install eslint --ext .js,.ts,.tsx .
```yml
name: Run ESLint on your changes only
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install modules
run: npm install
- name: Fetch the base branch
run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
- name: Run ESLint on your changes only
env:
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }}
run: npx --no-install eslint --ext .js,.jsx,.ts,.tsx .
```

### For BitBucket Pipelines
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.17.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-diff": "^2.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-promise": "^6.0.0",
"husky": "^8.0.1",
Expand Down
9 changes: 5 additions & 4 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getDiffForFile = (filePath: string, staged = false): string => {
[]
);

return child_process.execFileSync(COMMAND, args).toString();
return child_process.execFileSync(COMMAND, args, options).toString();
};

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

return child_process
.execFileSync(COMMAND, args)
.execFileSync(COMMAND, args, options)
.toString()
.trim()
.split("\n")
Expand All @@ -62,14 +62,15 @@ const hasCleanIndex = (filePath: string): boolean => {

let result = true;
try {
child_process.execFileSync(COMMAND, args).toString();
child_process.execFileSync(COMMAND, args, options).toString();
} catch (err: unknown) {
result = false;
}

return result;
};

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

const untrackedFileListCache = child_process
.execFileSync(COMMAND, args)
.execFileSync(COMMAND, args, options)
.toString()
.trim()
.split("\n")
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1891,11 +1891,6 @@ eslint-module-utils@^2.7.3:
debug "^3.2.7"
find-up "^2.1.0"

eslint-plugin-diff@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-diff/-/eslint-plugin-diff-2.0.0.tgz#d714ead965e04aef1f7e4f87eac292b84a5599bc"
integrity sha512-sSKwFOahooDy9ld60RJ4U696+FNP4bVrHaYsLFtJJXxkhujA+kAnxtmLF6PaUlBuFcTCtsYwyN13zkZKT8J1Uw==

eslint-plugin-import@^2.26.0:
version "2.26.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b"
Expand Down

0 comments on commit e6f2102

Please sign in to comment.