@sequencemedia/music-library 1.0.4 → 1.0.5
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/build/gulp/pre-commit.mjs +37 -7
- package/package.json +1 -1
|
@@ -18,22 +18,52 @@ const OPTIONS = {
|
|
|
18
18
|
maxBuffer: 1024 * 500
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const BRANCH = 'master'
|
|
22
|
+
|
|
23
|
+
const trim = (v) => v.split('\n').map((v) => v.trimEnd()).join('\n').trim()
|
|
24
|
+
|
|
25
|
+
function use (key) {
|
|
26
|
+
const log = debug(`@modernpoacher/deps:${key}`)
|
|
27
|
+
|
|
28
|
+
return function use (v) {
|
|
29
|
+
log(trim(v))
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getGitRemoteShowOriginHeadBranch () {
|
|
34
|
+
log('getGitRemoteShowOriginHeadBranch')
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
new Promise((resolve, reject) => {
|
|
38
|
+
const command = 'git remote show origin | awk \'/HEAD branch/ {print $NF}\''
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
stdout,
|
|
42
|
+
stderr
|
|
43
|
+
} = exec(command, OPTIONS, (e, v = '') => (!e) ? resolve(trim(v)) : reject(e))
|
|
44
|
+
|
|
45
|
+
stdout.on('data', use('git-remote-show-origin-head-branch'))
|
|
46
|
+
stderr.on('data', use('git-remote-show-origin-head-branch'))
|
|
47
|
+
})
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function hasPackageVersionChanges (branch = BRANCH) {
|
|
22
52
|
log('hasPackageVersionChanges')
|
|
23
53
|
|
|
24
54
|
return (
|
|
25
55
|
new Promise((resolve, reject) => {
|
|
26
|
-
exec(
|
|
56
|
+
exec(`git diff HEAD origin/${branch} package.json`, OPTIONS, (e, v) => (!e) ? resolve(PACKAGE_VERSION_CHANGES.test(v)) : reject(e))
|
|
27
57
|
})
|
|
28
58
|
)
|
|
29
59
|
}
|
|
30
60
|
|
|
31
|
-
export function notPackageVersionChanges () {
|
|
61
|
+
export function notPackageVersionChanges (branch = BRANCH) {
|
|
32
62
|
log('notPackageVersionChanges')
|
|
33
63
|
|
|
34
64
|
return (
|
|
35
65
|
new Promise((resolve, reject) => {
|
|
36
|
-
exec(
|
|
66
|
+
exec(`git diff HEAD origin/${branch} package.json`, OPTIONS, (e, v) => (!e) ? resolve(PACKAGE_VERSION_CHANGES.test(v) !== true) : reject(e))
|
|
37
67
|
})
|
|
38
68
|
)
|
|
39
69
|
}
|
|
@@ -58,12 +88,12 @@ export function notStagedChanges () {
|
|
|
58
88
|
)
|
|
59
89
|
}
|
|
60
90
|
|
|
61
|
-
export function notPushedChanges () {
|
|
91
|
+
export function notPushedChanges (branch = BRANCH) {
|
|
62
92
|
log('notPushedChanges')
|
|
63
93
|
|
|
64
94
|
return (
|
|
65
95
|
new Promise((resolve, reject) => {
|
|
66
|
-
exec(
|
|
96
|
+
exec(`git log origin/${branch}..HEAD`, OPTIONS, (e, v) => (!e) ? resolve(!!v) : reject(e))
|
|
67
97
|
})
|
|
68
98
|
)
|
|
69
99
|
}
|
|
@@ -103,7 +133,7 @@ export default async function preCommit () {
|
|
|
103
133
|
/**
|
|
104
134
|
* Not package version changes, continue
|
|
105
135
|
*/
|
|
106
|
-
if (await notPackageVersionChanges()) {
|
|
136
|
+
if (await notPackageVersionChanges(await getGitRemoteShowOriginHeadBranch())) {
|
|
107
137
|
await patchPackageVersion()
|
|
108
138
|
await addPackageVersionChanges()
|
|
109
139
|
}
|