Skip to content

Commit

Permalink
Fix "directories aren't cleaned up"
Browse files Browse the repository at this point in the history
Fixes #351
  • Loading branch information
nvuillam committed Feb 26, 2024
1 parent 9052bb8 commit ca4c633
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## UNRELEASED

## [14.2.3] 2024-02-26

- Fix [#351](https://github.com/nvuillam/npm-groovy-lint/issues/351): temp directories aren't cleaned up

## [14.2.2] 2024-02-18

- Fix `console.warning is not a function`
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## UNRELEASED

## [14.2.3] 2024-02-26

- Fix [#351](https://github.com/nvuillam/npm-groovy-lint/issues/351): temp directories aren't cleaned up

## [14.2.2] 2024-02-18

- Fix `console.warning is not a function`
Expand Down
6 changes: 6 additions & 0 deletions lib/groovy-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const debug = require("debug")("npm-groovy-lint");
const trace = require("debug")("npm-groovy-lint-trace");
const fs = require("fs-extra");
const os = require("os");
const path = require("path");
const performance = require("perf_hooks").performance;

const NpmGroovyLintFix = require("./groovy-lint-fix");
Expand Down Expand Up @@ -109,6 +110,11 @@ class NpmGroovyLint {

await fs.remove(this.tmpGroovyFileName);
debug(`Removed temp file ${this.tmpGroovyFileName} as it is not longer used :)`);
const tmpDir = path.dirname(this.tmpGroovyFileName);
if (tmpDir.includes("codeNarcTmpDir_") && fs.readdirSync(tmpDir).length === 0) {
await fs.remove(tmpDir);
debug(`Removed temp dir ${tmpDir} as it is not longer used :)`);
}
this.tmpGroovyFileName = null;
}

Expand Down

0 comments on commit ca4c633

Please sign in to comment.