lint-staged 17.0.2 → 17.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/execGit.js CHANGED
@@ -21,6 +21,7 @@ export const execGit = async (cmd, options) => {
21
21
  debugLog('Running git command:', cmd)
22
22
  const result = exec('git', [...NO_SUBMODULE_RECURSE, ...cmd], {
23
23
  nodeOptions: {
24
+ env: options?.env,
24
25
  cwd: options?.cwd,
25
26
  stdio: ['ignore'],
26
27
  },
@@ -294,16 +294,26 @@ export class GitWorkflow {
294
294
  }
295
295
  }
296
296
 
297
- // Unset GIT_INDEX_FILE so that the default index is always updated after running tasks
298
- // Otherwise committing a pathspec (which uses a temporary non-default index) will leave
299
- // changes in the worktree and default index
300
- debugLog('Unset GIT_INDEX_FILE (was `%s`)', process.env.GIT_INDEX_FILE)
301
- delete process.env.GIT_INDEX_FILE
297
+ const gitIndexFile = process.env.GIT_INDEX_FILE
298
+ ? normalizePath(process.env.GIT_INDEX_FILE)
299
+ : undefined
300
+
301
+ const adjustedGitIndexFile = gitIndexFile
302
+ ? gitIndexFile.endsWith('.git/index.lock')
303
+ ? // Relative and absolute default path should stay as-is
304
+ gitIndexFile
305
+ : // Non-default path is redirected to default
306
+ '.git/index.lock'
307
+ : undefined
302
308
 
303
309
  debugLog('Updating Git index again after task modifications...')
304
310
 
305
311
  // Update index for the files that were originally staged, ignore others
306
- await this.execGit(['update-index', '--again'])
312
+ await this.execGit(['update-index', '--again'], {
313
+ env: {
314
+ GIT_INDEX_FILE: adjustedGitIndexFile,
315
+ },
316
+ })
307
317
 
308
318
  debugLog('Done updating Git index again after task modifications!')
309
319
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "17.0.2",
3
+ "version": "17.0.3",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": {