Commit d83ebc8b by xzyfer

Use console for logging instead of npmlog

We started using npmlog for install logging in #1786, then went all
out in #1796. npmlog has caused some issues, namely #1805. It doesn't
provided enough value for how troublesome it is.

The problem sparked #1786 was resolved in 5c7fb7f6.
parent 79237e60
...@@ -7,7 +7,6 @@ var pkg = require('../package.json'), ...@@ -7,7 +7,6 @@ var pkg = require('../package.json'),
mkdir = require('mkdirp'), mkdir = require('mkdirp'),
path = require('path'), path = require('path'),
spawn = require('cross-spawn'), spawn = require('cross-spawn'),
log = require('npmlog'),
sass = require('../lib/extensions'); sass = require('../lib/extensions');
/** /**
...@@ -28,23 +27,23 @@ function afterBuild(options) { ...@@ -28,23 +27,23 @@ function afterBuild(options) {
mkdir(path.dirname(install), function(err) { mkdir(path.dirname(install), function(err) {
if (err && err.code !== 'EEXIST') { if (err && err.code !== 'EEXIST') {
log.error('node-sass build', err.message); console.error(err.message);
return; return;
} }
fs.stat(target, function(err) { fs.stat(target, function(err) {
if (err) { if (err) {
log.error('node-sass build', 'Build succeeded but target not found'); console.error('Build succeeded but target not found');
return; return;
} }
fs.rename(target, install, function(err) { fs.rename(target, install, function(err) {
if (err) { if (err) {
log.error('node-sass build', err.message); console.error(err.message);
return; return;
} }
log.info('node-sass build', 'Installed to %s', install); console.log('Installed to', install);
}); });
}); });
}); });
...@@ -76,8 +75,8 @@ function manageProcess(proc, cb) { ...@@ -76,8 +75,8 @@ function manageProcess(proc, cb) {
*/ */
function initSubmodules(cb) { function initSubmodules(cb) {
log.info('node-sass build', 'Detected a git install'); console.log('Detected a git install');
log.info('node-sass build', 'Cloning LibSass into src/libsass'); console.log('Cloning LibSass into src/libsass');
var clone = spawn('git', ['clone', 'https://github.com/sass/libsass.git', './src/libsass']); var clone = spawn('git', ['clone', 'https://github.com/sass/libsass.git', './src/libsass']);
manageProcess(clone, function(err) { manageProcess(clone, function(err) {
...@@ -86,7 +85,7 @@ function initSubmodules(cb) { ...@@ -86,7 +85,7 @@ function initSubmodules(cb) {
return; return;
} }
log.info('node-sass build', 'Checking out LibSass to %s', pkg.libsass); console.log('Checking out LibSass to', pkg.libsass);
var checkout = spawn('git', ['checkout', pkg.libsass], { cwd: './src/libsass' }); var checkout = spawn('git', ['checkout', pkg.libsass], { cwd: './src/libsass' });
manageProcess(checkout, function(err) { manageProcess(checkout, function(err) {
...@@ -128,7 +127,7 @@ function installGitDependencies(options, cb) { ...@@ -128,7 +127,7 @@ function installGitDependencies(options, cb) {
function build(options) { function build(options) {
installGitDependencies(options, function(err) { installGitDependencies(options, function(err) {
if (err) { if (err) {
log.error('node-sass build', err.message); console.error(err.message);
process.exit(1); process.exit(1);
} }
...@@ -137,7 +136,7 @@ function build(options) { ...@@ -137,7 +136,7 @@ function build(options) {
return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join(''); return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join('');
})).concat(options.args); })).concat(options.args);
log.info('node-sass build', [process.execPath].concat(args).join(' ')); console.log('Building:', [process.execPath].concat(args).join(' '));
var proc = spawn(process.execPath, args, { var proc = spawn(process.execPath, args, {
stdio: [0, 1, 2] stdio: [0, 1, 2]
...@@ -150,9 +149,9 @@ function build(options) { ...@@ -150,9 +149,9 @@ function build(options) {
} }
if (errorCode === 127 ) { if (errorCode === 127 ) {
log.error('node-sass build', 'node-gyp not found!'); console.error('node-gyp not found!');
} else { } else {
log.error('node-sass build', 'Build failed with error code: %d', errorCode); console.error('Build failed with error code:', errorCode);
} }
process.exit(1); process.exit(1);
...@@ -207,18 +206,18 @@ function testBinary(options) { ...@@ -207,18 +206,18 @@ function testBinary(options) {
return build(options); return build(options);
} }
log.info('node-sass build', 'Binary found at %s', sass.getBinaryPath()); console.log('Binary found at', sass.getBinaryPath());
log.info('node-sass build', 'Testing binary'); console.log('Testing binary');
try { try {
require('../').renderSync({ require('../').renderSync({
data: 's { a: ss }' data: 's { a: ss }'
}); });
log.info('node-sass build', 'Binary is fine'); console.log('Binary is fine');
} catch (e) { } catch (e) {
log.error('node-sass build', 'Binary has a problem: %s', e); console.log('Binary has a problem:', e);
log.info('node-sass build', 'Building the binary locally'); console.log('Building the binary locally');
return build(options); return build(options);
} }
......
...@@ -48,7 +48,7 @@ function download(url, dest, cb) { ...@@ -48,7 +48,7 @@ function download(url, dest, cb) {
return response.statusCode >= 200 && response.statusCode < 300; return response.statusCode >= 200 && response.statusCode < 300;
}; };
log.http('node-sass install', 'Downloading binary from %s', url); console.log('Downloading binary from', url);
try { try {
request(url, downloadOptions(), function(err, response) { request(url, downloadOptions(), function(err, response) {
...@@ -57,7 +57,7 @@ function download(url, dest, cb) { ...@@ -57,7 +57,7 @@ function download(url, dest, cb) {
} else if (!successful(response)) { } else if (!successful(response)) {
reportError(['HTTP error', response.statusCode, response.statusMessage].join(' ')); reportError(['HTTP error', response.statusCode, response.statusMessage].join(' '));
} else { } else {
log.http('node-sass install', 'Download complete'); console.log('Download complete');
cb(); cb();
} }
}) })
...@@ -94,7 +94,7 @@ function download(url, dest, cb) { ...@@ -94,7 +94,7 @@ function download(url, dest, cb) {
function checkAndDownloadBinary() { function checkAndDownloadBinary() {
if (process.env.SKIP_SASS_BINARY_DOWNLOAD_FOR_CI) { if (process.env.SKIP_SASS_BINARY_DOWNLOAD_FOR_CI) {
log.info('node-sass install', 'Skipping downloading binaries on CI builds'); console.log('Skipping downloading binaries on CI builds');
return; return;
} }
...@@ -103,45 +103,45 @@ function checkAndDownloadBinary() { ...@@ -103,45 +103,45 @@ function checkAndDownloadBinary() {
binaryPath = sass.getBinaryPath(); binaryPath = sass.getBinaryPath();
if (sass.hasBinary(binaryPath)) { if (sass.hasBinary(binaryPath)) {
log.info('node-sass build', 'Binary found at %s', binaryPath); console.log('node-sass build', 'Binary found at', binaryPath);
return; return;
} }
try { try {
mkdir.sync(path.dirname(binaryPath)); mkdir.sync(path.dirname(binaryPath));
} catch (err) { } catch (err) {
log.error('node-sass install', 'Unable to save binary to %s: %s', path.dirname(binaryPath), err); console.error('Unable to save binary', path.dirname(binaryPath), ':', err);
return; return;
} }
if (cachedBinary) { if (cachedBinary) {
log.info('node-sass install', 'Cached binary found at %s', cachedBinary); console.log('Cached binary found at', cachedBinary);
fs.createReadStream(cachedBinary).pipe(fs.createWriteStream(binaryPath)); fs.createReadStream(cachedBinary).pipe(fs.createWriteStream(binaryPath));
return; return;
} }
download(sass.getBinaryUrl(), binaryPath, function(err) { download(sass.getBinaryUrl(), binaryPath, function(err) {
if (err) { if (err) {
log.error('node-sass install', err); console.error(err);
return; return;
} }
log.info('node-sass install', 'Binary saved at %s', binaryPath); console.log('Binary saved to', binaryPath);
cachedBinary = path.join(cachePath, sass.getBinaryName()); cachedBinary = path.join(cachePath, sass.getBinaryName());
if (cachePath) { if (cachePath) {
log.info('node-sass install', 'Caching binary to %s', cachedBinary); console.log('Caching binary to', cachedBinary);
try { try {
mkdir.sync(path.dirname(cachedBinary)); mkdir.sync(path.dirname(cachedBinary));
fs.createReadStream(binaryPath) fs.createReadStream(binaryPath)
.pipe(fs.createWriteStream(cachedBinary)) .pipe(fs.createWriteStream(cachedBinary))
.on('error', function (err) { .on('error', function (err) {
log.error('node-sass install', 'Failed to cache binary: %s', err); console.log('Failed to cache binary:', err);
}); });
} catch (err) { } catch (err) {
log.error('node-sass install', 'Failed to cache binary: %s', err); console.log('Failed to cache binary:', 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