FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/lifecycleScripts/retrieveExternalDependencies.js at v0.3.2 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
21
(21)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
lifecycleScripts
/
retrieveExternalDependencies.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
113 lines (100 loc) · 3.31 KB
Breadcrumbs
nodegit
/
lifecycleScripts
/
retrieveExternalDependencies.js
Copy path
File metadata and controls
113 lines (100 loc) · 3.31 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
var
Promise
=
require
(
"nodegit-promise"
)
;
var
promisify
=
require
(
"promisify-node"
)
;
var
fse
=
promisify
(
"fs-extra"
)
;
var
zlib
=
require
(
"zlib"
)
;
var
cp
=
require
(
"child_process"
)
;
var
path
=
require
(
"path"
)
;
var
local
=
path
.
join
.
bind
(
path
,
__dirname
)
;
var
rooted
=
path
.
join
.
bind
(
path
,
__dirname
,
".."
)
;
var
check
=
require
(
local
(
"checkPrepared"
)
)
.
checkVendor
;
var
pkg
=
require
(
rooted
(
"package"
)
)
;
var
tar
;
var
request
;
var
NODE_VERSION
=
Number
(
process
.
version
.
match
(
/
^
v
(
\d
+
\.
\d
+
)
/
)
[
1
]
)
;
module
.
exports
=
function
retrieveExternalDependencies
(
)
{
tar
=
require
(
"tar"
)
;
request
=
require
(
"request"
)
;
return
Promise
.
all
(
[
getVendorLib
(
"libgit2"
)
,
getVendorLib
(
"libssh2"
)
,
getVendorLib
(
"http_parser"
)
]
)
;
}
;
function
getVendorLib
(
name
)
{
var
vendorPath
=
"vendor/"
+
name
+
"/"
;
var
vendorPackage
=
pkg
[
name
]
;
if
(
NODE_VERSION
===
0.1
&&
vendorPackage
[
"0.10"
]
)
{
vendorPackage
=
vendorPackage
[
"0.10"
]
;
}
var
version
=
vendorPackage
.
sha
||
vendorPackage
.
version
;
console
.
info
(
"[nodegit] Detecting "
+
vendorPath
+
version
+
"."
)
;
return
check
(
name
)
.
then
(
function
(
exists
)
{
if
(
exists
)
{
console
.
info
(
"[nodegit] "
+
vendorPath
+
version
+
" already exists."
)
;
return
Promise
.
resolve
(
)
;
}
else
{
return
check
(
name
,
true
)
.
then
(
function
(
exists
)
{
if
(
exists
)
{
console
.
info
(
"[nodegit] Removing outdated "
+
vendorPath
+
"."
)
;
return
fse
.
remove
(
rooted
(
vendorPath
)
)
;
}
else
{
console
.
info
(
"[nodegit] "
+
vendorPath
+
" not found."
)
;
return
Promise
.
resolve
(
)
;
}
}
)
.
then
(
function
(
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
console
.
info
(
"[nodegit] Retrieving "
+
vendorPath
+
"."
)
;
var
extract
=
tar
.
Extract
(
{
path
:
rooted
(
"vendor/"
+
name
+
"/"
)
,
strip
:
true
}
)
;
request
.
get
(
vendorPackage
.
url
)
.
pipe
(
zlib
.
createUnzip
(
)
)
.
pipe
(
extract
)
.
on
(
"error"
,
reject
)
.
on
(
"end"
,
resolve
)
;
}
)
;
}
)
.
then
(
function
(
)
{
return
fse
.
writeFile
(
rooted
(
vendorPath
+
version
)
,
""
)
;
}
)
.
then
(
function
(
)
{
if
(
(
name
==
"libssh2"
)
&&
(
process
.
platform
!==
"win32"
)
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
console
.
info
(
"[nodegit] Configuring libssh2."
)
;
cp
.
execFile
(
rooted
(
vendorPath
)
+
"configure"
,
{
cwd
:
rooted
(
vendorPath
)
}
,
function
(
err
,
stdout
,
stderr
)
{
if
(
err
)
{
console
.
error
(
err
)
;
console
.
error
(
stderr
)
;
reject
(
err
,
stderr
)
;
}
else
{
resolve
(
stdout
)
;
}
}
)
;
}
)
;
}
else
{
return
Promise
.
resolve
(
)
;
}
}
)
.
then
(
function
(
)
{
console
.
info
(
"[nodegit] Successfully updated "
+
vendorPath
+
version
+
"."
)
;
}
)
;
}
}
)
;
}
// Called on the command line
if
(
require
.
main
===
module
)
{
module
.
exports
(
)
;
}
Back
|
FazBrowse Home
|
New Git URL