@modernpoacher/hooks 1.0.399 → 1.0.401

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/.eslintignore CHANGED
@@ -1,5 +1,3 @@
1
1
  .circleci
2
2
  .github
3
- .husky
4
-
5
3
  node_modules
package/.eslintrc CHANGED
@@ -2,12 +2,11 @@
2
2
  "root": true,
3
3
  "extends": "standard",
4
4
  "env": {
5
- "node": true,
6
- "es2020": true
5
+ "node": true
7
6
  },
8
7
  "parser": "@babel/eslint-parser",
9
8
  "parserOptions": {
10
- "ecmaVersion": 2020,
9
+ "ecmaVersion": "latest",
11
10
  "sourceType": "module"
12
11
  }
13
12
  }
package/.gitattributes CHANGED
@@ -2,13 +2,22 @@
2
2
  * text=auto
3
3
 
4
4
  # LF line endings
5
+ *.yaml text eol=lf
6
+ *.yml text eol=lf
5
7
  *.json text eol=lf
6
8
  *.mjs text eol=lf
7
9
  *.cjs text eol=lf
10
+ *.jsx text eol=lf
8
11
  *.mts text eol=lf
12
+ *.cts text eol=lf
13
+ *.sh text eol=lf
9
14
  .editorconfig text eol=lf
10
15
  .eslintignore text eol=lf
11
16
  .eslintrc text eol=lf
12
17
  .gitattributes text eol=lf
13
18
  .gitignore text eol=lf
19
+ .npmignore text eol=lf
20
+ .npmrc text eol=lf
21
+ .eslintrc text eol=lf
22
+ .babelrc text eol=lf
14
23
  .husky/* text eol=lf
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/hooks",
3
- "version": "1.0.399",
3
+ "version": "1.0.401",
4
4
  "description": "Git Hooks",
5
5
  "keywords": [
6
6
  "git",
package/src/common.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  exec
5
5
  } from 'child_process'
6
6
 
7
- const log = debug('@modernpoacher/hooks:common')
7
+ const log = debug('@modernpoacher/hooks/common')
8
8
 
9
9
  log('`@modernpoacher/hooks` is awake')
10
10
 
@@ -23,7 +23,7 @@ export const NOT_STAGED_CHANGES = /Changes not staged for commit/s
23
23
  export const trim = (v = '') => String(v).split('\n').map((v) => v.trimEnd()).join('\n').trim()
24
24
 
25
25
  export function use (key) {
26
- const log = debug(`@modernpoacher/hooks:${key}`)
26
+ const log = debug(`@modernpoacher/hooks/${key}`)
27
27
 
28
28
  return function use (v) {
29
29
  log(trim(v))
@@ -48,6 +48,24 @@ export function getGitRemoteShowOriginHeadBranch () {
48
48
  )
49
49
  }
50
50
 
51
+ export function getGitRevParseAbbrevRefHead () {
52
+ log('getGitRevParseAbbrevRefHead')
53
+
54
+ return (
55
+ new Promise((resolve, reject) => {
56
+ const command = 'git rev-parse --abbrev-ref HEAD'
57
+
58
+ const {
59
+ stdout,
60
+ stderr
61
+ } = exec(command, OPTIONS, (e, v) => (!e) ? resolve(trim(v)) : reject(e))
62
+
63
+ stdout.on('data', use('git-rev-parse-head'))
64
+ stderr.on('data', use('git-rev-parse-head'))
65
+ })
66
+ )
67
+ }
68
+
51
69
  export function hasGitDiffHeadPackageVersionChanges (branch = BRANCH) {
52
70
  log('hasGitDiffHeadPackageVersionChanges')
53
71
 
@@ -3,12 +3,13 @@ import debug from 'debug'
3
3
  import {
4
4
  hasStagedChanges,
5
5
  getGitRemoteShowOriginHeadBranch,
6
+ getGitRevParseAbbrevRefHead,
6
7
  hasGitDiffHeadPackageVersionChanges,
7
8
  patchPackageVersion
8
9
  } from '#hooks/common'
9
10
 
10
- const log = debug('@modernpoacher/hooks:post-commit')
11
- const error = debug('@modernpoacher/hooks:post-commit:error')
11
+ const log = debug('@modernpoacher/hooks/post-commit')
12
+ const error = debug('@modernpoacher/hooks/post-commit:error')
12
13
 
13
14
  log('`@modernpoacher/hooks` is awake')
14
15
 
@@ -18,9 +19,12 @@ export default async function postCommit () {
18
19
  try {
19
20
  if (await hasStagedChanges()) return
20
21
 
21
- if (await hasGitDiffHeadPackageVersionChanges(await getGitRemoteShowOriginHeadBranch())) return
22
+ const originHeadBranch = await getGitRemoteShowOriginHeadBranch()
23
+ if (originHeadBranch === await getGitRevParseAbbrevRefHead()) {
24
+ if (await hasGitDiffHeadPackageVersionChanges(originHeadBranch)) return
22
25
 
23
- await patchPackageVersion()
26
+ await patchPackageVersion()
27
+ }
24
28
  } catch ({
25
29
  code = 'NONE',
26
30
  message = 'No error message defined'