Commit 25b54a7a by xzyfer

Replace progress modules with npmlog

parent e4091760
......@@ -64,7 +64,7 @@
"mkdirp": "^0.5.1",
"nan": "^2.3.2",
"node-gyp": "^3.3.1",
"progress": "^1.1.8",
"npmlog": "^4.0.0",
"request": "^2.61.0",
"sass-graph": "^2.1.1"
},
......
......@@ -8,7 +8,7 @@ var fs = require('fs'),
path = require('path'),
sass = require('../lib/extensions'),
request = require('request'),
ProgressBar = require('progress'),
log = require('npmlog'),
pkg = require('../package.json');
/**
......@@ -51,7 +51,7 @@ function download(url, dest, cb) {
var options = {
rejectUnauthorized: false,
proxy: getProxy(),
timeout: 60000,
timeout: 1000,
headers: {
'User-Agent': getUserAgent(),
}
......@@ -70,6 +70,9 @@ function download(url, dest, cb) {
}
})
.on('response', function(response) {
var length = parseInt(response.headers['content-length'], 10);
var progress = log.newItem(url, length);
if (successful(response)) {
response.pipe(fs.createWriteStream(dest));
}
......@@ -78,16 +81,12 @@ function download(url, dest, cb) {
// been explicitly set it's `undefined` which is considered
// as far as npm is concerned.
if (process.env.npm_config_progress !== false) {
var bar = new ProgressBar('Total :total [:bar] :current :percent :etas', {
complete: '=',
incomplete: ' ',
width: 25,
total: parseInt(response.headers['content-length'])
});
log.enableProgress();
response.on('data', function(chunk) {
bar.tick(chunk.length);
});
progress.completeWork(chunk.length);
})
.on('end', progress.finish);
}
});
} 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