FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/lifecycleScripts/submodules/index.js at master · jorisroling/nodegit · GitHub
jorisroling
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
lifecycleScripts
/
submodules
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (64 loc) · 2.14 KB
Breadcrumbs
nodegit
/
lifecycleScripts
/
submodules
/
index.js
Copy path
File metadata and controls
74 lines (64 loc) · 2.14 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
70
71
72
73
74
var
path
=
require
(
"path"
)
;
var
rootDir
=
path
.
join
(
__dirname
,
"../.."
)
;
var
gitExecutableLocation
=
require
(
path
.
join
(
rootDir
,
"./utils/gitExecutableLocation"
)
)
;
var
submoduleStatus
=
require
(
"./getStatus"
)
;
var
exec
=
require
(
path
.
join
(
rootDir
,
"./utils/execPromise"
)
)
;
module
.
exports
=
function
submodules
(
)
{
return
gitExecutableLocation
(
)
.
catch
(
function
(
)
{
console
.
log
(
"ERROR - Compilation of NodeGit requires git CLI to be "
+
"installed and on the path"
)
;
throw
new
Error
(
"git CLI is not installed or not on the path"
)
;
}
)
.
then
(
function
(
)
{
return
submoduleStatus
(
)
;
}
)
.
then
(
function
(
statuses
)
{
function
printSubmodule
(
submoduleName
)
{
console
.
log
(
"\t"
+
submoduleName
)
;
}
var
dirtySubmodules
=
statuses
.
filter
(
function
(
status
)
{
return
status
.
workDirDirty
&&
!
status
.
needsInitialization
;
}
)
.
map
(
function
(
dirtySubmodule
)
{
return
dirtySubmodule
.
name
;
}
)
;
if
(
dirtySubmodules
.
length
)
{
console
.
log
(
"ERROR - The following submodules have uncommited changes:"
)
;
dirtySubmodules
.
forEach
(
printSubmodule
)
;
console
.
log
(
"\nThey must either be committed or discarded before we build"
)
;
throw
new
Error
(
"Dirty Submodules: "
+
dirtySubmodules
.
join
(
" "
)
)
;
}
var
outOfSyncSubmodules
=
statuses
.
filter
(
function
(
status
)
{
return
status
.
onNewCommit
&&
!
status
.
needsInitialization
;
}
)
.
map
(
function
(
outOfSyncSubmodule
)
{
return
outOfSyncSubmodule
.
name
;
}
)
;
if
(
outOfSyncSubmodules
.
length
)
{
console
.
log
(
"WARNING - The following submodules are pointing to an new commit:"
)
;
outOfSyncSubmodules
.
forEach
(
printSubmodule
)
;
console
.
log
(
"\nThey will not be updated."
)
;
}
return
Promise
.
all
(
statuses
.
filter
(
function
(
status
)
{
return
!
status
.
onNewCommit
;
}
)
.
map
(
function
(
submoduleToUpdate
)
{
return
exec
(
"git submodule update --init --recursive "
+
submoduleToUpdate
.
name
)
;
}
)
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL