Skip to content

Commit 46e0ff8

Browse files
authored
fix(hook): hook is not being triggered on Mac OS X
* fix(hook): hook is not being triggered on `Mac OS X` * chore(hook): remove redundant shebang * feat(tslint): updated to 5.x * chore(packages): bump `@speedy/node-core`
1 parent f45ff71 commit 46e0ff8

7 files changed

Lines changed: 24 additions & 22 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Commit first line format:
1717
npm install @speedy/commit-msg-hook --save-dev
1818
```
1919

20-
Note: for Windows users, you might need to be install the package in `Administrator` mode. As on Windows only users with `SeCreateSymbolicLinkPrivilege` can create `Symbolic Links`, which is granted only to administrators by default.
21-
2220
## Rules
2321

2422
The majority of the rules can be applied in any part of the configuration.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"preversion": "npm test",
3333
"version": "npm run build && npm run changelog",
3434
"postversion": "git commit --all -m \"chore(all): update for release\" && git push && git push --tags",
35-
"release": "ts-node ./tools/modify-package && npm publish && git checkout ."
36-
},
35+
"release": "ts-node ./tools/modify-package ",
36+
"install": "node ./dist/installer install"},
3737
"dependencies": {
38-
"@speedy/node-core": "^1.0.0",
38+
"@speedy/node-core": "^1.0.1",
3939
"lodash": "^4.17.4"
4040
},
4141
"devDependencies": {
@@ -48,7 +48,7 @@
4848
"mock-fs": "^4.2.0",
4949
"rimraf": "^2.6.1",
5050
"ts-node": "^3.0.2",
51-
"tslint": "^4.5.1",
51+
"tslint": "^5.0.0",
5252
"typescript": "^2.2.0"
5353
},
5454
"typings": "dist/index.d.ts"

src/hook.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env node
2-
31
import { validator } from "./validator";
42

53
validator

src/installer.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mkdirSync, lstatSync, Stats, renameSync, unlinkSync, symlinkSync, existsSync } from "fs";
1+
import { mkdirSync, lstatSync, Stats, renameSync, constants, unlinkSync, writeFileSync, existsSync } from "fs";
22
import { join } from "path";
33
import { fileSystem } from "@speedy/node-core";
44

@@ -27,20 +27,23 @@ if (process.argv[2] === "uninstall") {
2727

2828
function install() {
2929
if (existsSync(hooksPath)) {
30-
uninstall();
31-
3230
if (fileStat && fileStat.isFile()) {
3331
renameSync(commitMsgHookPath, `${commitMsgHookPath}.backup`);
32+
} else {
33+
uninstall();
3434
}
3535
} else {
3636
mkdirSync(hooksPath);
3737
}
3838

39-
symlinkSync(join(__dirname, "hook.js"), commitMsgHookPath);
39+
const hookContent = `#!/usr/bin/env node
40+
require("${join(__dirname, "hook.js")}");`;
41+
42+
writeFileSync(commitMsgHookPath, hookContent, { mode: constants.S_IRWXU });
4043
}
4144

4245
function uninstall() {
43-
if (fileStat && fileStat.isSymbolicLink()) {
46+
if (fileStat) {
4447
unlinkSync(commitMsgHookPath);
4548
}
4649
}

src/validator/validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export namespace validator {
1212
export async function validate(commitMessage?: string, configFilePath?: string) {
1313
const configPath = config.getConfigFilePath(
1414
configFilePath || DEFAULT_CONFIG_FILENAME,
15-
join(__dirname, "../../config", DEFAULT_CONFIG_FILENAME)
15+
join(__dirname, "../../config")
1616
);
1717
const configData = await config.readConfigFile<ConfigData>(configPath);
1818
const { type, message, scope, subject } = configData.rules;

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"declaration": true,
99
"noImplicitReturns": true,
1010
"noImplicitAny": true,
11+
"noUnusedLocals": true,
12+
"noUnusedParameters": true,
1113
"noFallthroughCasesInSwitch": true,
1214
"allowUnreachableCode": false,
1315
"skipLibCheck": true,

tslint.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
true,
3232
140
3333
],
34+
"member-access": [
35+
true,
36+
"no-public"
37+
],
3438
"member-ordering": [
3539
true,
3640
{
@@ -78,16 +82,9 @@
7882
"no-string-throw": true,
7983
"no-switch-case-fall-through": false,
8084
"no-trailing-whitespace": true,
85+
"no-unnecessary-callback-wrapper": true,
8186
"no-unnecessary-initializer": true,
8287
"no-unused-expression": true,
83-
"no-unused-variable": [
84-
true,
85-
{
86-
"ignore-pattern": "^_"
87-
},
88-
"check-parameters"
89-
],
90-
"no-use-before-declare": true,
9188
"no-var-keyword": true,
9289
"object-literal-key-quotes": [
9390
true,
@@ -109,6 +106,10 @@
109106
],
110107
"prefer-const": true,
111108
"prefer-for-of": true,
109+
"prefer-template": [
110+
true,
111+
"allow-single-concat"
112+
],
112113
"quotemark": [
113114
true,
114115
"double"

0 commit comments

Comments
 (0)