@forsakringskassan/commitlint-config 3.0.1 → 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.
- package/dist/install.js +19 -2
- package/hooks.js +1 -1
- 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
|
-
|
|
849
|
-
|
|
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,6 +856,16 @@ if (process.env.FK_COMMITLINT_SKIP !== "1") {
|
|
|
856
856
|
process.exit(1);
|
|
857
857
|
}
|
|
858
858
|
if (!import_is_ci.default) {
|
|
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
|
+
}
|
|
859
869
|
const result = await spawn2(
|
|
860
870
|
"npm",
|
|
861
871
|
[
|
|
@@ -867,9 +877,16 @@ if (process.env.FK_COMMITLINT_SKIP !== "1") {
|
|
|
867
877
|
],
|
|
868
878
|
{ cwd: process.env["INIT_CWD"] }
|
|
869
879
|
);
|
|
880
|
+
if (result.output.toLowerCase().includes("error")) {
|
|
881
|
+
console.log(result.output);
|
|
882
|
+
process.exit(1);
|
|
883
|
+
}
|
|
870
884
|
console.log(result.output);
|
|
871
885
|
}
|
|
872
886
|
}
|
|
887
|
+
if (process.env.FK_COMMITLINT_SKIP !== "1") {
|
|
888
|
+
await setupGitHooks();
|
|
889
|
+
}
|
|
873
890
|
if (!import_is_ci.default) {
|
|
874
891
|
configureCommitTemplate();
|
|
875
892
|
}
|
package/hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
|
|
3
|
-
const lintConfigPath = fileURLToPath.meta.resolve("./lint-staged.js");
|
|
3
|
+
const lintConfigPath = fileURLToPath(import.meta.resolve("./lint-staged.js"));
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
"pre-commit": `npm exec lint-staged -- --config "${lintConfigPath}" "$@"`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/commitlint-config",
|
|
3
|
-
"version": "3.0.
|
|
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": "
|
|
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",
|