Commit 25b54a7a by xzyfer

Replace progress modules with npmlog

parent e4091760
...@@ -64,7 +64,7 @@ ...@@ -64,7 +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",
"progress": "^1.1.8", "npmlog": "^4.0.0",
"request": "^2.61.0", "request": "^2.61.0",
"sass-graph": "^2.1.1" "sass-graph": "^2.1.1"
}, },
......
...@@ -8,7 +8,7 @@ var fs = require('fs'), ...@@ -8,7 +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'),
ProgressBar = require('progress'), log = require('npmlog'),
pkg = require('../package.json'); pkg = require('../package.json');
/** /**
...@@ -51,7 +51,7 @@ function download(url, dest, cb) { ...@@ -51,7 +51,7 @@ function download(url, dest, cb) {
var options = { var options = {
rejectUnauthorized: false, rejectUnauthorized: false,
proxy: getProxy(), proxy: getProxy(),
timeout: 60000, timeout: 1000,
headers: { headers: {
'User-Agent': getUserAgent(), 'User-Agent': getUserAgent(),
} }
...@@ -70,6 +70,9 @@ function download(url, dest, cb) { ...@@ -70,6 +70,9 @@ 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));
} }
...@@ -78,16 +81,12 @@ function download(url, dest, cb) { ...@@ -78,16 +81,12 @@ function download(url, dest, cb) {
// been explicitly set it's `undefined` which is considered // been explicitly set it's `undefined` which is considered
// as far as npm is concerned. // as far as npm is concerned.
if (process.env.npm_config_progress !== false) { if (process.env.npm_config_progress !== false) {
var bar = new ProgressBar('Total :total [:bar] :current :percent :etas', { log.enableProgress();
complete: '=',
incomplete: ' ',
width: 25,
total: parseInt(response.headers['content-length'])
});
response.on('data', function(chunk) { response.on('data', function(chunk) {
bar.tick(chunk.length); progress.completeWork(chunk.length);
}); })
.on('end', progress.finish);
} }
}); });
} catch (err) { } catch (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment