gulp-sass/index.js
Neil Kinnish 86827e6eca Update error handling and handled partials
1. Updated so as an error is logged rather than reported as an error as this will stop the watcher which could be annoying - although may be a preference option?

2. Added logic to ignore a partial (doesn't log) essentially a sass file prefixed with '_'
2014-01-10 16:27:05 +00:00

46 lines
1.2 KiB
JavaScript

var es = require('event-stream')
, clone = require('clone')
, sass = require('node-sass')
, path = require('path')
, gutil = require('gulp-util')
, ext = gutil.replaceExtension
;
module.exports = function (options) {
var opts = options ? clone(options) : {};
function nodeSass (file, cb) {
// file is on object passed in by gulp
// file.contents is always a Buffer
if (path.basename(file.path).indexOf('_') === 0) {
//gutil.log('[gulp-sass] Partial: ' + path.basename(file.path) + ' ignored');
return cb();
}
if (file.isNull()) {
gutil.log('[gulp-sass] Empty file: ' + path.basename(file.path) + ' ignored');
return cb();
}
opts.data = file.contents.toString();
opts.success = function (css) {
file.path = ext(file.path, '.css');
file.shortened = file.shortened && ext(file.shortened, '.css');
file.contents = new Buffer(css);
cb(null, file);
}
opts.error = function (err) {
//return cb(new gutil.PluginError('gulp-imagemin', err));
gutil.log('[gulp-sass] Error: ' + err);
return cb();
}
sass.render(opts);
}
return es.map(nodeSass);
}