Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
0e3d809f
Commit
0e3d809f
authored
Feb 12, 2015
by
Adeel Mujahid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #663 from rubennorte/improve-install-script
Improve install script
parents
39b14d76
250d6cf9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
29 deletions
+22
-29
install.js
scripts/install.js
+22
-29
No files found.
scripts/install.js
View file @
0e3d809f
...
...
@@ -2,7 +2,9 @@ var fs = require('fs'),
path
=
require
(
'path'
),
request
=
require
(
'request'
),
mkdirp
=
require
(
'mkdirp'
),
exec
=
require
(
'shelljs'
).
exec
;
exec
=
require
(
'shelljs'
).
exec
,
npmconf
=
require
(
'npmconf'
),
packageInfo
=
require
(
'../package.json'
);
require
(
'../lib/extensions'
);
...
...
@@ -16,27 +18,17 @@ require('../lib/extensions');
*/
function
download
(
url
,
dest
,
cb
)
{
var
file
=
fs
.
createWriteStream
(
dest
);
applyProxy
({
rejectUnauthorized
:
false
},
function
(
options
)
{
var
returnError
=
function
(
err
)
{
fs
.
unlink
(
dest
);
cb
(
typeof
err
.
message
===
'string'
?
err
.
message
:
err
);
};
var
req
=
request
.
get
(
url
,
options
).
on
(
'response'
,
function
(
response
)
{
request
.
get
(
url
,
options
).
on
(
'response'
,
function
(
response
)
{
if
(
response
.
statusCode
<
200
||
response
.
statusCode
>=
300
)
{
returnError
(
'Can not download file from '
+
url
);
return
;
}
response
.
pipe
(
file
);
file
.
on
(
'finish'
,
function
()
{
file
.
close
(
cb
);
});
response
.
pipe
(
fs
.
createWriteStream
(
dest
));
}).
on
(
'error'
,
returnError
);
req
.
end
();
req
.
on
(
'error'
,
returnError
);
});
}
...
...
@@ -49,25 +41,26 @@ function download(url, dest, cb) {
*/
function
applyProxy
(
options
,
cb
)
{
require
(
'npmconf'
).
load
({},
function
(
er
,
conf
)
{
var
getProxyFromEnv
=
true
;
[
'https-proxy'
,
'proxy'
,
'http-proxy'
].
forEach
(
function
(
setting
)
{
var
proxyUrl
=
conf
.
get
(
setting
);
if
(
proxyUrl
&&
proxyUrl
===
require
(
'url'
).
parse
(
proxyUrl
))
{
options
.
proxy
=
proxyUrl
;
getProxyFromEnv
=
false
;
cb
(
options
);
return
;
npmconf
.
load
({},
function
(
er
,
conf
)
{
var
proxyUrl
;
if
(
!
er
)
{
[
'https-proxy'
,
'proxy'
,
'http-proxy'
].
some
(
function
(
setting
)
{
var
npmProxyUrl
=
conf
.
get
(
setting
);
if
(
npmProxyUrl
)
{
proxyUrl
=
npmProxyUrl
;
return
true
;
}
});
}
if
(
getProxyFromEnv
)
{
if
(
!
proxyUrl
)
{
var
env
=
process
.
env
;
options
.
proxy
=
env
.
HTTPS_PROXY
||
env
.
https_proxy
||
env
.
HTTP_PROXY
||
env
.
http_proxy
;
proxyUrl
=
env
.
HTTPS_PROXY
||
env
.
https_proxy
||
env
.
HTTP_PROXY
||
env
.
http_proxy
;
}
options
.
proxy
=
proxyUrl
;
cb
(
options
);
}
});
}
...
...
@@ -77,7 +70,7 @@ function applyProxy(options, cb) {
* @api private
*/
function
exist
s
()
{
function
checkAndFetchBinarie
s
()
{
fs
.
exists
(
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryName
),
function
(
exists
)
{
if
(
exists
)
{
return
;
...
...
@@ -96,7 +89,7 @@ function exists() {
function
fetch
()
{
var
url
=
[
'https://raw.githubusercontent.com/sass/node-sass-binaries/v'
,
require
(
'../package.json'
)
.
version
,
'/'
,
process
.
sassBinaryName
,
packageInfo
.
version
,
'/'
,
process
.
sassBinaryName
,
'/binding.node'
].
join
(
''
);
var
dir
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryName
);
...
...
@@ -132,4 +125,4 @@ if (process.env.SKIP_SASS_BINARY_DOWNLOAD_FOR_CI) {
* Run
*/
exist
s
();
checkAndFetchBinarie
s
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment