exec-staged 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -24,6 +24,10 @@ Install from npm, using your preferred package manager:
24
24
  npm install --save-dev exec-staged
25
25
  ```
26
26
 
27
+ ## Requirements
28
+
29
+ - Git >= 2.22.0
30
+
27
31
  ## Usage
28
32
 
29
33
  ### Run from the CLI
package/dist/lib/stage.js CHANGED
@@ -66,7 +66,7 @@ export class Stage {
66
66
  this.logger.log('⚠️ Git installation not found!');
67
67
  throw new Error('git installation not found');
68
68
  }
69
- if (!version || semver.lte(version, '2.13.0')) {
69
+ if (!version || semver.lt(version, '2.22.0')) {
70
70
  this.logger.log('⚠️ Unsupported git version!');
71
71
  throw new Error('unsupported git version');
72
72
  }
@@ -135,7 +135,8 @@ export class Stage {
135
135
  this.git([
136
136
  'diff',
137
137
  '--binary',
138
- '--default-prefix',
138
+ '--src-prefix=a/',
139
+ '--dst-prefix=b/',
139
140
  // skip deleted files because patch doesn't apply if they're modified
140
141
  '--diff-filter=d',
141
142
  '--no-color',
@@ -248,11 +249,12 @@ export class Stage {
248
249
  ]);
249
250
  // unstaged deletions are not included in the patch and must be handled
250
251
  // separately because the patch cannot be applied if such files are
251
- // modified by tasks
252
+ // modified by tasks; use force: true to handle cases where the file
253
+ // doesn't exist (e.g., unstaged renames)
252
254
  Object.entries(this.status)
253
255
  .filter(([, s]) => s.match(/^.D/))
254
256
  .map(([f]) => f)
255
- .forEach((f) => fs.rmSync(path.resolve(this.cwd, f)));
257
+ .forEach((f) => fs.rmSync(path.resolve(this.cwd, f), { force: true }));
256
258
  // make sure all restored unstaged changes are kept out of the index
257
259
  this.git(['reset']);
258
260
  // undo temporary commit while keeping its changes in the index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exec-staged",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Run commands against the current git index",
5
5
  "keywords": [
6
6
  "git",
package/src/lib/stage.ts CHANGED
@@ -85,7 +85,7 @@ export class Stage {
85
85
  throw new Error('git installation not found');
86
86
  }
87
87
 
88
- if (!version || semver.lte(version, '2.13.0')) {
88
+ if (!version || semver.lt(version, '2.22.0')) {
89
89
  this.logger.log('⚠️ Unsupported git version!');
90
90
  throw new Error('unsupported git version');
91
91
  }
@@ -185,7 +185,8 @@ export class Stage {
185
185
  this.git([
186
186
  'diff',
187
187
  '--binary',
188
- '--default-prefix',
188
+ '--src-prefix=a/',
189
+ '--dst-prefix=b/',
189
190
  // skip deleted files because patch doesn't apply if they're modified
190
191
  '--diff-filter=d',
191
192
  '--no-color',
@@ -323,11 +324,12 @@ export class Stage {
323
324
 
324
325
  // unstaged deletions are not included in the patch and must be handled
325
326
  // separately because the patch cannot be applied if such files are
326
- // modified by tasks
327
+ // modified by tasks; use force: true to handle cases where the file
328
+ // doesn't exist (e.g., unstaged renames)
327
329
  Object.entries(this.status)
328
330
  .filter(([, s]) => s.match(/^.D/))
329
331
  .map(([f]) => f)
330
- .forEach((f) => fs.rmSync(path.resolve(this.cwd, f)));
332
+ .forEach((f) => fs.rmSync(path.resolve(this.cwd, f), { force: true }));
331
333
 
332
334
  // make sure all restored unstaged changes are kept out of the index
333
335
  this.git(['reset']);