@forsakringskassan/commitlint-config 3.0.2 → 3.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.
Files changed (2) hide show
  1. package/dist/install.js +15 -5
  2. package/package.json +2 -2
package/dist/install.js CHANGED
@@ -845,8 +845,8 @@ function configureCommitTemplate() {
845
845
  console.info(`git ${args.join(" ")}`);
846
846
  spawnSync("git", args);
847
847
  }
848
- var originCwd = process.env["INIT_CWD"] || "";
849
- if (process.env.FK_COMMITLINT_SKIP !== "1") {
848
+ async function setupGitHooks() {
849
+ const originCwd = process.env["INIT_CWD"] || "";
850
850
  const packageJson = JSON.parse(
851
851
  await fsp.readFile(path4.join(originCwd, "package.json"), {
852
852
  encoding: "utf-8"
@@ -856,9 +856,16 @@ if (process.env.FK_COMMITLINT_SKIP !== "1") {
856
856
  process.exit(1);
857
857
  }
858
858
  if (!import_is_ci.default) {
859
- await spawn2("git", ["config", "--unset", "core.hooksPath"], {
860
- cwd: process.env["INIT_CWD"]
861
- });
859
+ try {
860
+ await spawn2("git", ["config", "--unset", "core.hooksPath"], {
861
+ cwd: process.env["INIT_CWD"]
862
+ });
863
+ } catch (error) {
864
+ if (!(error instanceof SubprocessError && error.exitCode === 5)) {
865
+ console.error(error);
866
+ process.exit(1);
867
+ }
868
+ }
862
869
  const result = await spawn2(
863
870
  "npm",
864
871
  [
@@ -877,6 +884,9 @@ if (process.env.FK_COMMITLINT_SKIP !== "1") {
877
884
  console.log(result.output);
878
885
  }
879
886
  }
887
+ if (process.env.FK_COMMITLINT_SKIP !== "1") {
888
+ await setupGitHooks();
889
+ }
880
890
  if (!import_is_ci.default) {
881
891
  configureCommitTemplate();
882
892
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/commitlint-config",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "FK commitlint shareable config",
5
5
  "keywords": [
6
6
  "commitlint"
@@ -47,7 +47,7 @@
47
47
  "pkg:mangle:pack": "release-prepack package.json --bundle --retain-scripts",
48
48
  "pkg:mangle:add": "npm pkg set scripts.postinstall=\"node bin/install.js\"",
49
49
  "pkg:restore": "release-postpack package.json",
50
- "prepare": "husky && git config commit.template gitmessage",
50
+ "prepare": "simple-git-hooks hooks.js && git config commit.template gitmessage",
51
51
  "prettier:check": "prettier . --check",
52
52
  "prettier:write": "prettier . --write",
53
53
  "pretest": "run-s eslint prettier:check",