FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/lifecycleScripts/submodules/getStatus.js at master · PendletonJones/nodegit · GitHub
PendletonJones
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
lifecycleScripts
/
submodules
/
getStatus.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (46 loc) · 1.72 KB
Breadcrumbs
nodegit
/
lifecycleScripts
/
submodules
/
getStatus.js
Copy path
File metadata and controls
50 lines (46 loc) · 1.72 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
var
path
=
require
(
"path"
)
;
var
rootDir
=
path
.
join
(
__dirname
,
"../.."
)
;
var
exec
=
require
(
path
.
join
(
rootDir
,
"./utils/execPromise"
)
)
;
module
.
exports
=
function
getStatus
(
)
{
return
exec
(
"git submodule status"
,
{
cwd
:
rootDir
}
)
.
then
(
function
(
stdout
)
{
if
(
!
stdout
)
{
// In the case where we pull from npm they pre-init the submodules for
// us and `git submodule status` returns empty-string. In that case
// we'll just assume that we're good.
return
Promise
.
resolve
(
[
]
)
;
}
function
getStatusPromiseFromLine
(
line
)
{
var
lineSections
=
line
.
trim
(
)
.
split
(
" "
)
;
var
onNewCommit
=
!
!
~
lineSections
[
0
]
.
indexOf
(
"+"
)
;
var
needsInitialization
=
!
!
~
lineSections
[
0
]
.
indexOf
(
"-"
)
;
var
commitOid
=
lineSections
[
0
]
.
replace
(
"+"
,
""
)
.
replace
(
"-"
,
""
)
;
var
name
=
lineSections
[
1
]
;
return
exec
(
"git status"
,
{
cwd
:
path
.
join
(
rootDir
,
name
)
}
)
.
then
(
function
(
workDirStatus
)
{
return
{
commitOid
:
commitOid
,
onNewCommit
:
onNewCommit
,
name
:
name
,
needsInitialization
:
needsInitialization
,
workDirDirty
:
!
~
workDirStatus
.
trim
(
)
.
split
(
"\n"
)
.
pop
(
)
.
indexOf
(
"nothing to commit"
)
}
;
}
)
;
}
return
Promise
.
all
(
stdout
.
trim
(
)
.
split
(
"\n"
)
.
map
(
getStatusPromiseFromLine
)
)
;
}
)
.
catch
(
function
(
)
{
// In the case that NodeGit is required from another project via npm we
// won't be able to run submodule commands but that's ok since the
// correct version of libgit2 is published with nodegit.
return
Promise
.
resolve
(
[
]
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL