FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cz-cli/src/commitizen/commit.js at master · ctrlplusb/cz-cli · GitHub
ctrlplusb
/
cz-cli
Public
forked from
commitizen/cz-cli
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
cz-cli
/
src
/
commitizen
/
commit.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (58 loc) · 2.27 KB
Breadcrumbs
cz-cli
/
src
/
commitizen
/
commit.js
Copy path
File metadata and controls
69 lines (58 loc) · 2.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import
path
from
'path'
;
import
dedent
from
'dedent'
;
import
cacheDir
from
'cachedir'
;
import
{
ensureDir
}
from
'fs-extra'
;
import
{
commit
as
gitCommit
,
log
}
from
'../git'
;
import
*
as
cache
from
'./cache'
;
export
default
commit
;
/**
* Takes all of the final inputs needed in order to make dispatch a git commit
*/
function
dispatchGitCommit
(
sh
,
repoPath
,
template
,
options
,
overrideOptions
,
done
)
{
// Commit the user input -- side effect that we'll test
gitCommit
(
sh
,
repoPath
,
template
,
{
...
options
,
...
overrideOptions
}
,
function
(
error
)
{
done
(
error
,
template
)
;
}
)
;
}
/**
* Asynchronously commits files using commitizen
*/
function
commit
(
sh
,
inquirer
,
repoPath
,
prompter
,
options
,
done
)
{
var
cacheDirectory
=
cacheDir
(
'commitizen'
)
;
var
cachePath
=
path
.
join
(
cacheDirectory
,
'commitizen.json'
)
;
ensureDir
(
cacheDirectory
,
function
(
error
)
{
if
(
error
)
{
console
.
error
(
"Couldn't create commitizen cache directory: "
,
error
)
;
// TODO: properly handle error?
}
else
{
if
(
options
.
retryLastCommit
)
{
console
.
log
(
'Retrying last commit attempt.'
)
;
// We want to use the last commit instead of the current commit,
// so lets override some options using the values from cache.
let
{
options
:
retryOptions
,
overrideOptions
:
retryOverrideOptions
,
template
:
retryTemplate
}
=
cache
.
getCacheValueSync
(
cachePath
,
repoPath
)
;
dispatchGitCommit
(
sh
,
repoPath
,
retryTemplate
,
retryOptions
,
retryOverrideOptions
,
done
)
;
}
else
{
// Get user input -- side effect that is hard to test
prompter
(
inquirer
,
function
(
error
,
template
,
overrideOptions
)
{
// Allow adapters to error out
// (error: Error?, template: String, overrideOptions: Object)
if
(
!
(
error
instanceof
Error
)
)
{
overrideOptions
=
template
;
template
=
error
;
error
=
null
;
}
if
(
error
)
{
return
done
(
error
)
;
}
// We don't want to add retries to the cache, only actual commands
cache
.
setCacheValueSync
(
cachePath
,
repoPath
,
{
template
,
options
,
overrideOptions
}
)
;
dispatchGitCommit
(
sh
,
repoPath
,
template
,
options
,
overrideOptions
,
done
)
;
}
)
;
}
}
}
)
;
}
Back
|
FazBrowse Home
|
New Git URL