@pnpm/patching.apply-patch 2.0.3 → 2.0.4

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/index.js CHANGED
@@ -2,17 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyPatchToDir = void 0;
4
4
  const error_1 = require("@pnpm/error");
5
- const applyPatches_1 = require("patch-package/dist/applyPatches");
5
+ const applyPatches_1 = require("@pnpm/patch-package/dist/applyPatches");
6
6
  function applyPatchToDir(opts) {
7
7
  // Ideally, we would just run "patch" or "git apply".
8
8
  // However, "patch" is not available on Windows and "git apply" is hard to execute on a subdirectory of an existing repository
9
9
  const cwd = process.cwd();
10
10
  process.chdir(opts.patchedDir);
11
- const success = (0, applyPatches_1.applyPatch)({
12
- patchDir: opts.patchedDir,
13
- patchFilePath: opts.patchFilePath,
14
- });
15
- process.chdir(cwd);
11
+ let success = false;
12
+ try {
13
+ success = (0, applyPatches_1.applyPatch)({
14
+ patchFilePath: opts.patchFilePath,
15
+ });
16
+ }
17
+ catch (err) { // eslint-disable-line
18
+ if (err.code === 'ENOENT') {
19
+ throw new error_1.PnpmError('PATCH_NOT_FOUND', `Patch file not found: ${opts.patchFilePath}`);
20
+ }
21
+ throw new error_1.PnpmError('INVALID_PATCH', `Applying patch "${opts.patchFilePath}" failed: ${err.message}`);
22
+ }
23
+ finally {
24
+ process.chdir(cwd);
25
+ }
16
26
  if (!success) {
17
27
  throw new error_1.PnpmError('PATCH_FAILED', `Could not apply patch ${opts.patchFilePath} to ${opts.patchedDir}`);
18
28
  }
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,kEAA4D;AAO5D,SAAgB,eAAe,CAAE,IAAyB;IACxD,qDAAqD;IACrD,8HAA8H;IAC9H,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,E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E;QACZ,MAAM,IAAI,iBAAS,CAAC,cAAc,EAAE,yBAAyB,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;KACzG;AACH,CAAC;AArBD,0CAqBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/patching.apply-patch",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Apply a patch to a directory",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -23,19 +23,22 @@
23
23
  },
24
24
  "homepage": "https://github.com/pnpm/pnpm/blob/main/patching/apply-patch#readme",
25
25
  "dependencies": {
26
- "patch-package": "^7.0.0",
26
+ "@pnpm/patch-package": "0.0.0",
27
27
  "@pnpm/error": "5.0.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@pnpm/patching.apply-patch": "2.0.3"
30
+ "@pnpm/patching.apply-patch": "2.0.4",
31
+ "@pnpm/prepare": "0.0.70",
32
+ "@pnpm/test-fixtures": "0.0.39"
31
33
  },
32
34
  "funding": "https://opencollective.com/pnpm",
33
35
  "exports": {
34
36
  ".": "./lib/index.js"
35
37
  },
36
38
  "scripts": {
37
- "test": "pnpm run compile",
39
+ "_test": "jest",
40
+ "test": "pnpm run compile && pnpm run _test",
38
41
  "compile": "tsc --build && pnpm run lint --fix",
39
- "lint": "eslint \"src/**/*.ts\""
42
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\""
40
43
  }
41
44
  }