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
cb8f1e43
Commit
cb8f1e43
authored
Apr 29, 2015
by
Michael Mifsud
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #907 from xzyfer/feat/install/user-agent
Set User-Agent: HTTP header
parents
b50533ae
1fd8d140
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
14 deletions
+22
-14
install.js
scripts/install.js
+22
-14
No files found.
scripts/install.js
View file @
cb8f1e43
...
@@ -6,7 +6,8 @@ var fs = require('fs'),
...
@@ -6,7 +6,8 @@ var fs = require('fs'),
mkdir
=
require
(
'mkdirp'
),
mkdir
=
require
(
'mkdirp'
),
npmconf
=
require
(
'npmconf'
),
npmconf
=
require
(
'npmconf'
),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
request
=
require
(
'request'
);
request
=
require
(
'request'
),
package
=
require
(
'../package.json'
);
require
(
'../lib/extensions'
);
require
(
'../lib/extensions'
);
...
@@ -21,21 +22,28 @@ require('../lib/extensions');
...
@@ -21,21 +22,28 @@ require('../lib/extensions');
function
download
(
url
,
dest
,
cb
)
{
function
download
(
url
,
dest
,
cb
)
{
var
returnError
=
function
(
err
)
{
var
returnError
=
function
(
err
)
{
cb
(
typeof
err
.
message
===
'string'
?
err
.
message
:
err
);
cb
(
typeof
err
.
message
===
'string'
?
err
.
message
:
err
);
};
};
if
(
url
)
{
if
(
url
)
{
applyProxy
({
rejectUnauthorized
:
false
},
function
(
options
)
{
applyProxy
({
rejectUnauthorized
:
false
},
function
(
options
)
{
request
.
get
(
url
,
options
).
on
(
'response'
,
function
(
response
)
{
options
.
headers
=
{
if
(
response
.
statusCode
<
200
||
response
.
statusCode
>=
300
)
{
'User-Agent'
:
[
returnError
([
'Can not download file from:'
,
url
].
join
());
'node/'
,
process
.
version
,
' '
,
return
;
'node-sass-installer/'
,
package
.
version
}
].
join
(
''
)
};
response
.
pipe
(
fs
.
createWriteStream
(
dest
));
request
.
get
(
url
,
options
).
on
(
'response'
,
function
(
response
)
{
if
(
response
.
statusCode
<
200
||
response
.
statusCode
>=
300
)
{
cb
();
returnError
([
'Can not download file from:'
,
url
].
join
());
}).
on
(
'error'
,
returnError
);
return
;
});
}
response
.
pipe
(
fs
.
createWriteStream
(
dest
));
cb
();
}).
on
(
'error'
,
returnError
);
});
}
else
{
}
else
{
returnError
(
'Download URL not defined, set SASS_BINARY_SITE in the environment to enable download.'
);
returnError
(
'Download URL not defined, set SASS_BINARY_SITE in the environment to enable download.'
);
}
}
...
...
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