@dotcom-tool-kit/package-json-hook 4.0.0 → 4.2.0

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.
@@ -28,24 +28,20 @@ class PackageJsonHelper extends types_1.Hook {
28
28
  return Array.isArray(this.field) ? [...this.field, this.key] : [this.field, this.key];
29
29
  }
30
30
  async check() {
31
- var _a;
32
31
  const packageJson = await this.getPackageJson();
33
- return (_a = (0, get_1.default)(packageJson, this.hookPath)) === null || _a === void 0 ? void 0 : _a.includes(this.hook);
32
+ return (0, get_1.default)(packageJson, this.hookPath)?.includes(this.hook);
34
33
  }
35
34
  async install(state) {
36
- state !== null && state !== void 0 ? state : (state = {});
35
+ state ??= {};
37
36
  // prepend each hook to maintain the same order as previous implementations
38
- (0, update_1.default)(state, this.hookPath, (hookState) => {
39
- var _a;
40
- return ({
41
- hooks: [this.hook, ...((_a = hookState === null || hookState === void 0 ? void 0 : hookState.hooks) !== null && _a !== void 0 ? _a : [])],
42
- trailingString: this.trailingString
43
- });
44
- });
37
+ (0, update_1.default)(state, this.hookPath, (hookState) => ({
38
+ hooks: [this.hook, ...(hookState?.hooks ?? [])],
39
+ trailingString: this.trailingString
40
+ }));
45
41
  return state;
46
42
  }
47
43
  async commitInstall(state) {
48
- const reduceHooks = (state) => (0, mapValues_1.default)(state, (field) => Array.isArray(field === null || field === void 0 ? void 0 : field.hooks)
44
+ const reduceHooks = (state) => (0, mapValues_1.default)(state, (field) => Array.isArray(field?.hooks)
49
45
  ? `dotcom-tool-kit ${field.hooks.join(' ')}${field.trailingString ? ' ' + field.trailingString : ''}`
50
46
  : reduceHooks(field));
51
47
  const newPackageJson = (0, merge_1.default)(await this.getPackageJson(), reduceHooks(state));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcom-tool-kit/package-json-hook",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "",
5
5
  "main": "lib",
6
6
  "scripts": {
@@ -32,5 +32,9 @@
32
32
  ],
33
33
  "volta": {
34
34
  "extends": "../../package.json"
35
+ },
36
+ "engines": {
37
+ "node": "16.x || 18.x || 20.x",
38
+ "npm": "7.x || 8.x || 9.x || 10.x"
35
39
  }
36
40
  }