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
ba3a2e01
Commit
ba3a2e01
authored
Sep 04, 2016
by
Michael Mifsud
Committed by
GitHub
Sep 04, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1694 from xzyfer/feat/progress-bar
Add a nice little progress bar while downloading binary
parents
7bf34bee
25b54a7a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
package.json
package.json
+1
-0
install.js
scripts/install.js
+18
-0
No files found.
package.json
View file @
ba3a2e01
...
@@ -64,6 +64,7 @@
...
@@ -64,6 +64,7 @@
"
mkdirp
"
:
"^0.5.1"
,
"
mkdirp
"
:
"^0.5.1"
,
"
nan
"
:
"^2.3.2"
,
"
nan
"
:
"^2.3.2"
,
"
node-gyp
"
:
"^3.3.1"
,
"
node-gyp
"
:
"^3.3.1"
,
"
npmlog
"
:
"^4.0.0"
,
"
request
"
:
"^2.61.0"
,
"
request
"
:
"^2.61.0"
,
"
sass-graph
"
:
"^2.1.1"
"
sass-graph
"
:
"^2.1.1"
},
},
...
...
scripts/install.js
View file @
ba3a2e01
...
@@ -8,6 +8,7 @@ var fs = require('fs'),
...
@@ -8,6 +8,7 @@ var fs = require('fs'),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
sass
=
require
(
'../lib/extensions'
),
sass
=
require
(
'../lib/extensions'
),
request
=
require
(
'request'
),
request
=
require
(
'request'
),
log
=
require
(
'npmlog'
),
pkg
=
require
(
'../package.json'
);
pkg
=
require
(
'../package.json'
);
/**
/**
...
@@ -56,6 +57,8 @@ function download(url, dest, cb) {
...
@@ -56,6 +57,8 @@ function download(url, dest, cb) {
}
}
};
};
console
.
log
(
'Start downloading binary at'
,
url
);
try
{
try
{
request
(
url
,
options
,
function
(
err
,
response
)
{
request
(
url
,
options
,
function
(
err
,
response
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -67,9 +70,24 @@ function download(url, dest, cb) {
...
@@ -67,9 +70,24 @@ function download(url, dest, cb) {
}
}
})
})
.
on
(
'response'
,
function
(
response
)
{
.
on
(
'response'
,
function
(
response
)
{
var
length
=
parseInt
(
response
.
headers
[
'content-length'
],
10
);
var
progress
=
log
.
newItem
(
url
,
length
);
if
(
successful
(
response
))
{
if
(
successful
(
response
))
{
response
.
pipe
(
fs
.
createWriteStream
(
dest
));
response
.
pipe
(
fs
.
createWriteStream
(
dest
));
}
}
// The `progress` is true by default. However if it has not
// been explicitly set it's `undefined` which is considered
// as far as npm is concerned.
if
(
process
.
env
.
npm_config_progress
!==
false
)
{
log
.
enableProgress
();
response
.
on
(
'data'
,
function
(
chunk
)
{
progress
.
completeWork
(
chunk
.
length
);
})
.
on
(
'end'
,
progress
.
finish
);
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
cb
(
err
);
cb
(
err
);
...
...
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