From 1dd861e4d6e0daa560c085a75dfdf6344954b814 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Mon, 23 Mar 2015 22:01:12 +0000 Subject: [PATCH 01/48] Rewrite gulp-sass to be a very light wrapper Simply pass everything to node-sass and just hand back the results to gulp. Removed custom options like success/failure cb and sync rendering. Missing: - gulp-sourcemaps support + test --- .travis.yml | 2 + README.md | 56 +------ index.js | 110 +++---------- package.json | 19 ++- test/{ref => expected}/inheritance.css | 5 +- test/{ref => expected}/mixins.css | 0 test/{ref => expected}/variables.css | 0 test/main.js | 124 +++++++++++++++ test/ref/nesting.css | 9 -- test/scss/_partial.scss | 3 + test/scss/error.scss | 3 + test/scss/include-path-tests/file1.scss | 1 - test/scss/include-path-tests/file2.scss | 2 - test/scss/includes/_cats.scss | 2 +- test/scss/inheritance.scss | 2 +- test/scss/nesting.scss | 14 -- test/scss/subdir/multilevelimport.scss | 1 - test/scss/variables.scss | 2 +- test/test.js | 200 ------------------------ 19 files changed, 174 insertions(+), 381 deletions(-) rename test/{ref => expected}/inheritance.css (66%) rename test/{ref => expected}/mixins.css (100%) rename test/{ref => expected}/variables.css (100%) create mode 100644 test/main.js delete mode 100644 test/ref/nesting.css create mode 100644 test/scss/_partial.scss create mode 100644 test/scss/error.scss delete mode 100644 test/scss/include-path-tests/file1.scss delete mode 100644 test/scss/include-path-tests/file2.scss delete mode 100644 test/scss/nesting.scss delete mode 100644 test/scss/subdir/multilevelimport.scss delete mode 100644 test/test.js diff --git a/.travis.yml b/.travis.yml index 6e5919d..067df8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ language: node_js node_js: - "0.10" + - node + - iojs diff --git a/README.md b/README.md index f6e62d4..6c82a0a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Sass plugin for [gulp](https://github.com/gulpjs/gulp). # Install ``` -npm install gulp-sass +npm install gulp-sass --save-dev ``` # Basic Usage @@ -19,38 +19,19 @@ Something like this: ```javascript var gulp = require('gulp'); +var gutil = require('gulp-util'); var sass = require('gulp-sass'); gulp.task('sass', function () { gulp.src('./scss/*.scss') - .pipe(sass()) + .pipe(sass().on('error', gutil.log)) .pipe(gulp.dest('./css')); }); ``` Options passed as a hash into `sass()` will be passed along to [`node-sass`](https://github.com/sass/node-sass). -If you want to use the indented syntax (`.sass`) as the top level file, use `sass({indentedSyntax: true})`. - -## gulp-sass specific options - -#### `errLogToConsole: true` - -If you pass `errLogToConsole: true` into the options hash, sass errors will be logged to the console instead of generating a `gutil.PluginError` object. Use this option with `gulp.watch` to keep gulp from stopping every time you mess up your sass. - -#### `onSuccess: callback` - -Pass in your own callback to be called upon successful compilation by node-sass. The callback has the form `callback(css)`, and is passed the compiled css as a string. Note: This *does not* prevent gulp-sass's default behavior of writing the output css file. - -#### `onError: callback` - -Pass in your own callback to be called upon a sass error from node-sass. The callback has the form `callback(err)`, where err is the error string generated by libsass. Note: this *does* prevent an actual `gulpPluginError` object from being created. - -#### `sync: true` - -If you pass `sync: true` into the options hash, sass.renderSync will be called, instead of sass.render. This should help when memory and/or cpu usage is getting very high when rendering many and/or big files. - -## Source Maps +## Source Maps TODO gulp-sass can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the SASS to CSS compilation. You will need to initialize [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) prior to running the gulp-sass compiler and write the source maps after. @@ -80,35 +61,6 @@ gulp.src('./scss/*.scss') // will write the source maps to ./dest/css/maps ``` -# Imports and Partials - -gulp-sass now automatically passes along the directory of every scss file it parses as an include path for node-sass. This means that as long as you specify your includes relative to path of your scss file, everything will just work. - -scss/includes/_settings.scss: - -```scss -$blue: #3bbfce; -$margin: 16px; -``` - -scss/style.scss: - -```scss -@import "includes/settings"; - -.content-navigation { - border-color: $blue; - color: - darken($blue, 9%); -} - -.border { - padding: $margin / 2; - margin: $margin / 2; - border-color: $blue; -} -``` - # Issues Before submitting an issue, please understand that gulp-sass is only a wrapper for [node-sass](https://github.com/sass/node-sass), which in turn is a node front end for [libsass](https://github.com/sass/libsass). Missing sass features and errors should not be reported here. diff --git a/index.js b/index.js index bc25a1e..7abe0af 100644 --- a/index.js +++ b/index.js @@ -1,104 +1,38 @@ -var fs = require('fs') - , map = require('map-stream') - , nodeSass = require('node-sass') - , path = require('path') - , gutil = require('gulp-util') - , clone = require('clone') - , ext = gutil.replaceExtension - , applySourceMap = require('vinyl-sourcemaps-apply') - ; +var gutil = require("gulp-util"); +var through = require("through2"); +var assign = require("object-assign"); +var path = require('path'); +var sass = require("node-sass"); -module.exports = function (options) { - - function sass (file, cb) { - var opts = options ? clone(options) : {}; - var fileDir = path.dirname(file.path); +var PLUGIN_NAME = 'gulp-sass'; +module.exports = function(options) { + return through.obj(function(file, enc, cb) { if (file.isNull()) { return cb(null, file); } + if (file.isStream()) { + return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported')); + } if (path.basename(file.path).indexOf('_') === 0) { return cb(); } - if (file.sourceMap) { - opts.sourceMap = file.path; - } - - opts.data = file.contents.toString(); + var opts = assign({}, options); opts.file = file.path; - if (opts.includePaths && Array.isArray(opts.includePaths)) { - if (opts.includePaths.indexOf(fileDir) === -1) { - opts.includePaths.push(fileDir); - } - } else { - opts.includePaths = [fileDir]; - } - - opts.success = function (obj) { - if (typeof opts.onSuccess === 'function') opts.onSuccess(obj); - - if (obj.map && typeof obj.map === 'string') { - // hack to remove the already added sourceMappingURL from libsass - obj.css = obj.css.replace(/\/\*#\s*sourceMappingURL\=.*\*\//, ''); - - // libsass gives us sources' paths relative to file; - // gulp-sourcemaps needs sources' paths relative to file.base; - // so alter the sources' paths to please gulp-sourcemaps. - obj.map = JSON.parse(obj.map); - - if (obj.map.sources) { - obj.map.sources = obj.map.sources.map(function(source) { - var abs = path.resolve(path.dirname(file.path), source); - return path.relative(file.base, abs); - }); - - obj.map = JSON.stringify(obj.map); - applySourceMap(file, obj.map); - } - + var callback = function(error, obj) { + if (error) { + return cb(new gutil.PluginError( + PLUGIN_NAME, error.message + ' on line ' + error.line + ' in ' + error.file + )); } - handleOutput(obj, file, cb); + file.contents = new Buffer(obj.css); + file.path = gutil.replaceExtension(file.path, '.css'); + cb(null, file); }; - opts.error = function (err) { - if (opts.errLogToConsole) { - gutil.log(gutil.colors.red('[gulp-sass]', err.message, 'on line', err.line + 'in', err.file)); - return cb(); - } - - if (typeof opts.onError === 'function') { - opts.onError(err); - return cb(); - } - - err.lineNumber = err.line; - err.fileName = err.file; - - return cb(new gutil.PluginError('gulp-sass', err)); - }; - - if ( opts.sync ) { - try { - var output = nodeSass.renderSync(opts); - opts.success(output); - handleOutput(output, file, cb); - } catch(err) { - opts.error(err); - } - } else { - nodeSass.render(opts); - } - - } - - return map(sass); + sass.render(opts, callback); + }); }; - -function handleOutput(output, file, cb) { - file.path = ext(file.path, '.css'); - file.contents = new Buffer(output.css); - cb(null, file); -} diff --git a/package.json b/package.json index c80e7ef..78b61df 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "gulp-sass", - "version": "1.3.3", + "version": "2.0.0", "description": "Gulp plugin for sass", "main": "index.js", "scripts": { - "test": "node test/test.js" + "test": "./node_modules/.bin/jshint index.js && ./node_modules/.bin/mocha test" }, "repository": { "type": "git", @@ -21,17 +21,16 @@ "url": "https://github.com/dlmanning/gulp-sass/issues" }, "dependencies": { - "clone": "~0.1.18", "gulp-util": "^3.0", - "map-stream": "~0.1", - "node-sass": "^2.0.1", + "node-sass": "^3.0.0-alpha.0", + "object-assign": "^2.0.0", + "through2": "^0.6.3", "vinyl-sourcemaps-apply": "~0.1.1" }, "devDependencies": { - "tape": "~2.3", - "concat-stream": "~1.4" - }, - "jshintConfig": { - "laxcomma": true + "gulp-sourcemaps": "^1.5.1", + "jshint": "^2.6.3", + "mocha": "^2.2.1", + "should": "^5.2.0" } } diff --git a/test/ref/inheritance.css b/test/expected/inheritance.css similarity index 66% rename from test/ref/inheritance.css rename to test/expected/inheritance.css index 1e58035..d2c002a 100644 --- a/test/ref/inheritance.css +++ b/test/expected/inheritance.css @@ -1,8 +1,11 @@ +body { + background: pink; } + .error, .badError { border: #f00; background: #fdd; } -.error.intrusion { +.error.intrusion, .intrusion.badError { font-size: 1.3em; font-weight: bold; } diff --git a/test/ref/mixins.css b/test/expected/mixins.css similarity index 100% rename from test/ref/mixins.css rename to test/expected/mixins.css diff --git a/test/ref/variables.css b/test/expected/variables.css similarity index 100% rename from test/ref/variables.css rename to test/expected/variables.css diff --git a/test/main.js b/test/main.js new file mode 100644 index 0000000..9a616c4 --- /dev/null +++ b/test/main.js @@ -0,0 +1,124 @@ +var should = require("should"); +var gutil = require("gulp-util"); +var path = require("path"); +var fs = require("fs"); +var sourcemaps = require('gulp-sourcemaps'); +var sass = require("../index"); + +function createVinyl(filename, contents) { + var base = path.join(__dirname, "scss"); + var filePath = path.join(base, filename); + + return new gutil.File({ + cwd: __dirname, + base: base, + path: filePath, + contents: contents || fs.readFileSync(filePath) + }); +} + +describe("gulp-sass", function() { + it("should pass file when it isNull()", function(done) { + var stream = sass(); + var emptyFile = { + isNull: function () { return true; } + }; + stream.on('data', function(data) { + data.should.equal(emptyFile); + done(); + }); + stream.write(emptyFile); + }); + + it('should emit error when file isStream()', function (done) { + var stream = sass(); + var streamFile = { + isNull: function () { return false; }, + isStream: function () { return true; } + }; + stream.on('error', function(err) { + err.message.should.equal('Streaming not supported'); + done(); + }); + stream.write(streamFile); + }); + + it("should compile a single sass file", function(done) { + var sassFile = createVinyl("mixins.scss"); + var stream = sass(); + stream.on("data", function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8') + ); + done(); + }); + stream.write(sassFile); + }); + + it("should compile multiple sass files", function(done) { + var files = [ + createVinyl('mixins.scss'), + createVinyl('variables.scss') + ]; + var stream = sass(); + var mustSee = files.length; + + stream.on("data", function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + var expectedPath = 'expected/mixins.css'; + if (cssFile.path.indexOf("variables") !== -1) { + expectedPath = 'expected/variables.css'; + } + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, expectedPath), 'utf8') + ); + mustSee--; + if (mustSee <= 0) { + done(); + } + }); + + files.forEach(function (file) { + stream.write(file); + }); + }); + + it("should compile files with partials in another folder", function(done) { + var sassFile = createVinyl("inheritance.scss"); + var stream = sass(); + stream.on("data", function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, 'expected/inheritance.css'), 'utf8') + ); + done(); + }); + stream.write(sassFile); + }); + + it("should handle sass errors", function(done) { + var errorFile = createVinyl("error.scss"); + var stream = sass(); + + stream.on("error", function(err) { + err.message.indexOf('property "font" must be followed by a \':\'').should.equal(0); + done(); + }); + stream.write(errorFile); + }); + + it("should work with gulp-sourcemaps", function(done) { + // TODO + done(); + }); +}); diff --git a/test/ref/nesting.css b/test/ref/nesting.css deleted file mode 100644 index 5a7d6bb..0000000 --- a/test/ref/nesting.css +++ /dev/null @@ -1,9 +0,0 @@ -table.hl { - margin: 2em 0; } - table.hl td.ln { - text-align: right; } - -li { - font-family: serif; - font-weight: bold; - font-size: 1.2em; } diff --git a/test/scss/_partial.scss b/test/scss/_partial.scss new file mode 100644 index 0000000..67ce83e --- /dev/null +++ b/test/scss/_partial.scss @@ -0,0 +1,3 @@ +body { + background: red; +} diff --git a/test/scss/error.scss b/test/scss/error.scss new file mode 100644 index 0000000..313f3bb --- /dev/null +++ b/test/scss/error.scss @@ -0,0 +1,3 @@ +body { + font 'Comic Sans'; +} diff --git a/test/scss/include-path-tests/file1.scss b/test/scss/include-path-tests/file1.scss deleted file mode 100644 index c7ca445..0000000 --- a/test/scss/include-path-tests/file1.scss +++ /dev/null @@ -1 +0,0 @@ -@import "cats"; diff --git a/test/scss/include-path-tests/file2.scss b/test/scss/include-path-tests/file2.scss deleted file mode 100644 index 6ccb45b..0000000 --- a/test/scss/include-path-tests/file2.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import "cats"; - diff --git a/test/scss/includes/_cats.scss b/test/scss/includes/_cats.scss index 5dd0283..9811f45 100644 --- a/test/scss/includes/_cats.scss +++ b/test/scss/includes/_cats.scss @@ -2,5 +2,5 @@ $blue: #3bbfce; $margin: 16px; body { - background: pink; + background: pink; } diff --git a/test/scss/inheritance.scss b/test/scss/inheritance.scss index f3caa92..f42ec79 100644 --- a/test/scss/inheritance.scss +++ b/test/scss/inheritance.scss @@ -13,4 +13,4 @@ .badError { @extend .error; border-width: 3px; -} \ No newline at end of file +} diff --git a/test/scss/nesting.scss b/test/scss/nesting.scss deleted file mode 100644 index d3300ea..0000000 --- a/test/scss/nesting.scss +++ /dev/null @@ -1,14 +0,0 @@ -table.hl { - margin: 2em 0; - td.ln { - text-align: right; - } -} - -li { - font: { - family: serif; - weight: bold; - size: 1.2em; - } -} diff --git a/test/scss/subdir/multilevelimport.scss b/test/scss/subdir/multilevelimport.scss deleted file mode 100644 index 4b7c1c3..0000000 --- a/test/scss/subdir/multilevelimport.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../inheritance"; diff --git a/test/scss/variables.scss b/test/scss/variables.scss index 7c5de0f..7deebf3 100644 --- a/test/scss/variables.scss +++ b/test/scss/variables.scss @@ -11,4 +11,4 @@ $margin: 16px; padding: $margin / 2; margin: $margin / 2; border-color: $blue; -} \ No newline at end of file +} diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 53cab23..0000000 --- a/test/test.js +++ /dev/null @@ -1,200 +0,0 @@ -var assert = require('assert'); -var gsass = require('../'); -var gutil = require('gulp-util'); -var fs = require('fs'); -var path = require('path'); -var test = require('tape'); - -function createVinyl(sassFileName, contents, base) { - base = base || path.join(__dirname, 'scss'); - var filePath = path.join(base, sassFileName); - - return new gutil.File({ - cwd: __dirname, - base: base, - path: filePath, - contents: contents || fs.readFileSync(filePath) - }); -} - -test('pass file when isNull()', function (t) { - var stream = gsass(); - var emptyFile = { - isNull: function () { return true; } - }; - stream.on('data', function (data) { - t.equal(data, emptyFile); - t.end(); - }); - stream.write(emptyFile); -}); - -// test('emit error when file isStream()', function (t) { -// var stream = gsass(); -// var streamFile = { -// isNull: function () { return false; }, -// isStream: function () { return true; } -// }; -// stream.on() -// }); - -test('compile a single sass file', function (t) { - var sassFile = createVinyl('mixins.scss'); - - var stream = gsass(); - stream.on('data', function (cssFile) { - t.ok(cssFile, 'cssFile should exist'); - t.ok(cssFile.path, 'cssFile.path should exist'); - t.ok(cssFile.relative, 'cssFile.relative should exist'); - t.ok(cssFile.contents, 'cssFile.contents should exist'); - t.equal(cssFile.path, path.join(__dirname, 'scss', 'mixins.css')); - t.equal( - fs.readFileSync(path.join(__dirname, 'ref/mixins.css'), 'utf8'), - cssFile.contents.toString(), - 'file compiles correctly to css' - ); - t.end(); - }) - stream.write(sassFile); -}); - -test('compile a single sass file synchronously', function (t) { - var sassFile = createVinyl('mixins.scss'); - - var stream = gsass({sync: true}); - stream.on('data', function (cssFile) { - t.ok(cssFile, 'cssFile should exist'); - t.ok(cssFile.path, 'cssFile.path should exist'); - t.ok(cssFile.relative, 'cssFile.relative should exist'); - t.ok(cssFile.contents, 'cssFile.contents should exist'); - t.equal(cssFile.path, path.join(__dirname, 'scss', 'mixins.css')); - t.equal( - fs.readFileSync(path.join(__dirname, 'ref/mixins.css'), 'utf8'), - cssFile.contents.toString(), - 'file compiles correctly to css' - ); - t.end(); - }) - stream.write(sassFile); -}); - -test('compile multiple sass files', function (t) { - var files = [ - createVinyl('inheritance.scss'), - createVinyl('mixins.scss'), - createVinyl('nesting.scss'), - createVinyl('variables.scss') - ]; - - t.plan(files.length * 4); - var stream = gsass(); - - stream.on('data', function (cssFile) { - t.ok(cssFile, 'cssFile exists'); - t.ok(cssFile.path, 'cssFile.path exists'); - t.ok(cssFile.relative, 'cssFile.relative exists'); - t.ok(cssFile.contents, 'cssFile.contents exists'); - }); - - files.forEach(function (file) { - stream.write(file); - }); -}); - -test('compile multiple sass files with includePaths', function (t) { - var files = [ - createVinyl('file1.scss', null, path.join(__dirname, 'scss', 'include-path-tests')), - createVinyl('file2.scss', null, path.join(__dirname, 'scss', 'include-path-tests')) - ]; - var options = { - includePaths: [path.resolve(__dirname, 'scss', 'includes')] - }; - - t.plan(files.length * 4); - var stream = gsass(options); - - stream.on('data', function (cssFile) { - t.ok(cssFile, 'cssFile exists'); - t.ok(cssFile.path, 'cssFile.path exists'); - t.ok(cssFile.relative, 'cssFile.relative exists'); - t.ok(cssFile.contents, 'cssFile.contents exists'); - }); - - files.forEach(function (file) { - stream.write(file); - }); -}); - -test('emit error on sass errors', function (t) { - var stream = gsass(); - var errorFile = createVinyl('somefile.sass', - new Buffer('body { font \'Comic Sans\'; }')); - stream.on('error', function (err) { - t.equal(err.message, - 'property "font" must be followed by a \':\'' - ); - t.end(); - }); - stream.write(errorFile); -}); - -test('emit error on sass errors when using sync true', function (t) { - var stream = gsass({sync: true}); - var errorFile = createVinyl('somefile.sass', - new Buffer('body { font \'Comic Sans\'; }')); - stream.on('error', function (err) { - t.equal(err.message, - 'property "font" must be followed by a \':\'' - ); - t.end(); - }); - stream.write(errorFile); -}); - -test('call custom error callback when opts.onError is given', function (t) { - var stream = gsass({ onError: function (err) { - t.equal(err.message, - 'property "font" must be followed by a \':\'' - ); - t.end(); - }}); - - var errorFile = createVinyl('somefile.sass', - new Buffer('body { font \'Comic Sans\'; }')); - - stream.write(errorFile); -}); - -test('sourcemaps', function (t) { - var sassFile = createVinyl('subdir/multilevelimport.scss'); - - // Pretend sourcemap.init() happened by mimicking - // the object it would create. - - sassFile.sourceMap = '{' + - '"version": 3,' + - '"file": "scss/subdir/multilevelimport.scss",' + - '"names": [],' + - '"mappings": "",' + - '"sources": [ "scss/subdir/multilevelimport.scss" ],' + - '"sourcesContent": [ "@import ../inheritance;" ]' + - '}'; - - // Expected sources are relative to file.base - var expectedSources = [ - 'includes/_cats.scss', - 'inheritance.scss' - ]; - - var stream = gsass(); - - stream.on('data', function (cssFile) { - t.deepEqual( - cssFile.sourceMap.sources, - expectedSources, - 'sourcemap paths are relative to file.base' - ); - t.end(); - }); - stream.write(sassFile); -}); From c4d97cc7fd312eca73aaf4749b47f96f59e64f4e Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 04:39:23 -0500 Subject: [PATCH 02/48] Updated node-sass version to alpha.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 78b61df..6c75efb 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "gulp-util": "^3.0", - "node-sass": "^3.0.0-alpha.0", + "node-sass": "^3.0.0-alpha.1", "object-assign": "^2.0.0", "through2": "^0.6.3", "vinyl-sourcemaps-apply": "~0.1.1" From abb28ba65e66841cf7d10cd1c54f33e8c24e4026 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 04:40:48 -0500 Subject: [PATCH 03/48] Sourcemap Support ported from 1.x --- index.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/index.js b/index.js index 7abe0af..86addb6 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ var through = require("through2"); var assign = require("object-assign"); var path = require('path'); var sass = require("node-sass"); +var applySourceMap = require('vinyl-sourcemaps-apply'); var PLUGIN_NAME = 'gulp-sass'; @@ -21,6 +22,11 @@ module.exports = function(options) { var opts = assign({}, options); opts.file = file.path; + // Generate Source Maps if plugin source-map present + if (file.sourceMap) { + opts.sourceMap = file.path; + } + var callback = function(error, obj) { if (error) { return cb(new gutil.PluginError( @@ -28,8 +34,30 @@ module.exports = function(options) { )); } + // Build Source Maps! + if (obj.map) { + // hack to remove the already added sourceMappingURL from libsass + obj.css = obj.css.toString().replace(/\/\*#\s*sourceMappingURL\=.*\*\//, ''); + + // libsass gives us sources' paths relative to file; + // gulp-sourcemaps needs sources' paths relative to file.base; + // so alter the sources' paths to please gulp-sourcemaps. + obj.map = JSON.parse(obj.map.toString()); + + if (obj.map.sources) { + obj.map.sources = obj.map.sources.map(function(source) { + var abs = path.resolve(path.dirname(file.path), source); + return path.relative(file.base, abs); + }); + + obj.map = JSON.stringify(obj.map); + applySourceMap(file, obj.map); + } + } + file.contents = new Buffer(obj.css); file.path = gutil.replaceExtension(file.path, '.css'); + cb(null, file); }; From 73b945367bc776def06edfb0c4f564403cb1b8f1 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 04:41:16 -0500 Subject: [PATCH 04/48] Sourcemap Tests --- test/main.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/test/main.js b/test/main.js index 9a616c4..776593f 100644 --- a/test/main.js +++ b/test/main.js @@ -2,8 +2,8 @@ var should = require("should"); var gutil = require("gulp-util"); var path = require("path"); var fs = require("fs"); -var sourcemaps = require('gulp-sourcemaps'); var sass = require("../index"); +var assert = require('assert'); function createVinyl(filename, contents) { var base = path.join(__dirname, "scss"); @@ -118,7 +118,30 @@ describe("gulp-sass", function() { }); it("should work with gulp-sourcemaps", function(done) { - // TODO - done(); + var sassFile = createVinyl("inheritance.scss"); + + // Expected sources are relative to file.base + var expectedSources = [ + 'includes/_cats.scss', + 'inheritance.scss' + ]; + + sassFile.sourceMap = '{' + + '"version": 3,' + + '"file": "scss/inheritance.scss",' + + '"names": [],' + + '"mappings": "",' + + '"sources": [ "scss/inheritance.scss" ],' + + '"sourcesContent": [ "@import includes/cats;" ]' + + '}'; + + var stream = sass(); + stream.on("data", function(cssFile) { + should.exist(cssFile.sourceMap); + assert.deepEqual(cssFile.sourceMap.sources, expectedSources); + done(); + }); + stream.write(sassFile); + }); }); From 480820b93714898fc8583d8ba52c07d5ce025cf7 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 04:51:57 -0500 Subject: [PATCH 05/48] omitSourceMapUrl instead of hack Node Sass now returns a buffer, so we don't need to turn it into a buffer for the contents --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 86addb6..73058aa 100644 --- a/index.js +++ b/index.js @@ -25,6 +25,7 @@ module.exports = function(options) { // Generate Source Maps if plugin source-map present if (file.sourceMap) { opts.sourceMap = file.path; + opts.omitSourceMapUrl = true; } var callback = function(error, obj) { @@ -36,9 +37,6 @@ module.exports = function(options) { // Build Source Maps! if (obj.map) { - // hack to remove the already added sourceMappingURL from libsass - obj.css = obj.css.toString().replace(/\/\*#\s*sourceMappingURL\=.*\*\//, ''); - // libsass gives us sources' paths relative to file; // gulp-sourcemaps needs sources' paths relative to file.base; // so alter the sources' paths to please gulp-sourcemaps. @@ -55,7 +53,7 @@ module.exports = function(options) { } } - file.contents = new Buffer(obj.css); + file.contents = obj.css; file.path = gutil.replaceExtension(file.path, '.css'); cb(null, file); From 8ca25e10adb9db2a572e194528c43b1f8209689c Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 05:32:12 -0500 Subject: [PATCH 06/48] Added linting Linting modified from ibm-watson/runner for use in Node --- .editorconfig | 21 +++++++ .eslintrc | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + test/lint.js | 49 ++++++++++++++++ 4 files changed, 226 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintrc create mode 100644 test/lint.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2cdfb8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 2 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..7275491 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,155 @@ +env: + mocha: true + node: true + +# globals: + ######################### + ## Only add globals if you're absolutely certain they need to be globals + ########################## + # console: true + +######################### +## set to 0 to allow +## set to 1 to disallow as warning +## set to 2 to disallow as error +######################### +rules: + ######################### + ## Optional Rules + ######################### + # Disallow use of `console` + no-console: 2 + + # Disallow warning comments + no-warning-comments: + - 1 + - terms + - todo + - fixme + location + - anywhere + + # Warns when variables are defined but never used + no-unused-vars: 1 + + # Enforces comma style (first or last) + comma-style: + - 2 + - last + + # Enforces one true `this` variable + consistent-this: + - 2 + - self + # Allows dangling underscores in identifiers + no-underscore-dangle: 2 + + # Enforces function expressions to have a name + func-names: 0 + + # Set maximum depth of nested callbacks + max-nested-callbacks: + - 1 + - 3 + + ######################### + ## Core Rules + ########################## + # Enforces camel case names + camelcase: 2 + + # Prohibit use of == and != in favor of === and !== + eqeqeq: 2 + + # Suppresses warnings about == null comparisons + no-eq-null: 2 + + # No mixing tabs and spaces, with 2 spaces only + no-mixed-spaces-and-tabs: 2 + + # Prohibits use of a variable before it is defined + no-use-before-define: 2 + + # Requires capitalized names for constructor functions + new-cap: 2 + + # Prohibits use of explicitly undeclared variables + no-undef: 2 + + # Enforces Use Strict at the top of function scope + strict: + - 2 + - global + + # Requires variable declarations to be at the top + vars-on-top: 2 + + # Enforce curly braces around blocks in loops and conditionals + curly: 2 + + # Prohibits the use of immediate function invocations w/o wrapping in parentheses + wrap-iife: 2 + + # Prohibits `argument.caller` and `argument.callee` + no-caller: 2 + + # Requires all `for in` loops to filter object's items + guard-for-in: 2 + + # Prohibits comparing a variable against itself + no-self-compare: 2 + + # Prohibits use of `undefined` variable + no-undefined: 0 + + # Prohibits nested ternaries + no-nested-ternary: 2 + + # Enforces a space before blocks + space-before-blocks: + - 2 + - always + + # Enforces spaces following keywords + space-after-keywords: + - 2 + - always + - checkFunctionKeyword: true + + # Enforces quoted property names + quote-props: + - 2 + - always + + # Enforces padded blocks + padded-blocks: + - 1 + - never + + # Enforce functions as expressions + func-style: + - 2 + - expression + + # Require brace style + brace-style: + - 2 + - stroustrup + + # Prohibits Yoda conditions + yoda: + - 2 + - never + + # Enforce use of single quotation marks for strings. + quotes: + - 2 + - single + + # Enforces space inside of brackets (except property name) + space-in-brackets: + - 2 + - always + - propertyName: false + singleValue: false + diff --git a/package.json b/package.json index 6c75efb..7d7a8ff 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "vinyl-sourcemaps-apply": "~0.1.1" }, "devDependencies": { + "eslint": "^0.17.1", "gulp-sourcemaps": "^1.5.1", "jshint": "^2.6.3", "mocha": "^2.2.1", diff --git a/test/lint.js b/test/lint.js new file mode 100644 index 0000000..1183f3b --- /dev/null +++ b/test/lint.js @@ -0,0 +1,49 @@ +'use strict'; + +var eslint = require('eslint'); +var should = require('should'); + +var cli = new eslint.CLIEngine(); +var formatter = cli.getFormatter(); + +var report; + +describe('style-guide', function() { + it('index.js should follow our lint style guide', function(done) { + report = cli.executeOnFiles(['index.js']); + if (report.errorCount > 0 || report.warningCount > 0) { + console.log(formatter(report.results)); + } + + should(report.errorCount).equal(0); + should(report.warningCount).equal(0); + done(); + }); + + it('test/main.js should follow our lint style guide', function(done) { + report = cli.executeOnFiles(['test/main.js']); + if (report.errorCount > 0 || report.warningCount > 0) { + console.log(formatter(report.results)); + } + + should(report.errorCount).equal(0); + should(report.warningCount).equal(0); + done(); + }); + + it('test/lint.js should follow our lint style guide', function(done) { + cli = new eslint.CLIEngine({ + 'rules': { + 'no-console': 0 + } + }); + report = cli.executeOnFiles(['test/lint.js']); + if (report.errorCount > 0 || report.warningCount > 0) { + console.log(formatter(report.results)); + } + + should(report.errorCount).equal(0); + should(report.warningCount).equal(0); + done(); + }); +}); From 3928f02b0154872b6fc89a33da0b4345cff7e266 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 05:37:48 -0500 Subject: [PATCH 07/48] Function version of 'use strict' for index.js --- test/lint.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/lint.js b/test/lint.js index 1183f3b..ca12181 100644 --- a/test/lint.js +++ b/test/lint.js @@ -10,6 +10,11 @@ var report; describe('style-guide', function() { it('index.js should follow our lint style guide', function(done) { + cli = new eslint.CLIEngine({ + 'rules': { + 'strict': [ 2, 'function' ] + } + }); report = cli.executeOnFiles(['index.js']); if (report.errorCount > 0 || report.warningCount > 0) { console.log(formatter(report.results)); From ae3fa21a3a98aab8524f989d6010f8a7d180a166 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 05:38:03 -0500 Subject: [PATCH 08/48] Fixed linting issues with index.js --- index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 73058aa..5e6c871 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,19 @@ -var gutil = require("gulp-util"); -var through = require("through2"); -var assign = require("object-assign"); -var path = require('path'); -var sass = require("node-sass"); +var gutil = require('gulp-util'); +var through = require('through2'); +var assign = require('object-assign'); +var path = require('path'); +var sass = require('node-sass'); var applySourceMap = require('vinyl-sourcemaps-apply'); var PLUGIN_NAME = 'gulp-sass'; module.exports = function(options) { + 'use strict'; + return through.obj(function(file, enc, cb) { + var opts, + callback; + if (file.isNull()) { return cb(null, file); } @@ -19,7 +24,7 @@ module.exports = function(options) { return cb(); } - var opts = assign({}, options); + opts = assign({}, options); opts.file = file.path; // Generate Source Maps if plugin source-map present @@ -28,7 +33,7 @@ module.exports = function(options) { opts.omitSourceMapUrl = true; } - var callback = function(error, obj) { + callback = function(error, obj) { if (error) { return cb(new gutil.PluginError( PLUGIN_NAME, error.message + ' on line ' + error.line + ' in ' + error.file From 47e6b7c772403bed984ee8183474a79d3971268c Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 05:52:43 -0500 Subject: [PATCH 09/48] Make strict rules more specific --- test/lint.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/lint.js b/test/lint.js index ca12181..a744f18 100644 --- a/test/lint.js +++ b/test/lint.js @@ -8,7 +8,7 @@ var formatter = cli.getFormatter(); var report; -describe('style-guide', function() { +describe('code style guide', function() { it('index.js should follow our lint style guide', function(done) { cli = new eslint.CLIEngine({ 'rules': { @@ -26,6 +26,11 @@ describe('style-guide', function() { }); it('test/main.js should follow our lint style guide', function(done) { + cli = new eslint.CLIEngine({ + 'rules': { + 'strict': [ 2, 'global' ] + } + }); report = cli.executeOnFiles(['test/main.js']); if (report.errorCount > 0 || report.warningCount > 0) { console.log(formatter(report.results)); @@ -39,7 +44,8 @@ describe('style-guide', function() { it('test/lint.js should follow our lint style guide', function(done) { cli = new eslint.CLIEngine({ 'rules': { - 'no-console': 0 + 'no-console': 0, + 'strict': [ 2, 'global' ] } }); report = cli.executeOnFiles(['test/lint.js']); From a096e3cfb04a07c199a24daca084625c16b7166e Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 05:53:01 -0500 Subject: [PATCH 10/48] Updated main to coding standards --- test/main.js | 85 +++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/test/main.js b/test/main.js index 776593f..df4f8c6 100644 --- a/test/main.js +++ b/test/main.js @@ -1,27 +1,31 @@ -var should = require("should"); -var gutil = require("gulp-util"); -var path = require("path"); -var fs = require("fs"); -var sass = require("../index"); +'use strict'; + +var should = require('should'); +var gutil = require('gulp-util'); +var path = require('path'); +var fs = require('fs'); +var sass = require('../index'); var assert = require('assert'); -function createVinyl(filename, contents) { - var base = path.join(__dirname, "scss"); +var createVinyl = function createVinyl(filename, contents) { + var base = path.join(__dirname, 'scss'); var filePath = path.join(base, filename); return new gutil.File({ - cwd: __dirname, - base: base, - path: filePath, - contents: contents || fs.readFileSync(filePath) + 'cwd': __dirname, + 'base': base, + 'path': filePath, + 'contents': contents || fs.readFileSync(filePath) }); -} +}; -describe("gulp-sass", function() { - it("should pass file when it isNull()", function(done) { +describe('gulp-sass', function() { + it('should pass file when it isNull()', function(done) { var stream = sass(); var emptyFile = { - isNull: function () { return true; } + 'isNull': function () { + return true; + } }; stream.on('data', function(data) { data.should.equal(emptyFile); @@ -33,8 +37,12 @@ describe("gulp-sass", function() { it('should emit error when file isStream()', function (done) { var stream = sass(); var streamFile = { - isNull: function () { return false; }, - isStream: function () { return true; } + 'isNull': function () { + return false; + }, + 'isStream': function () { + return true; + } }; stream.on('error', function(err) { err.message.should.equal('Streaming not supported'); @@ -43,10 +51,10 @@ describe("gulp-sass", function() { stream.write(streamFile); }); - it("should compile a single sass file", function(done) { - var sassFile = createVinyl("mixins.scss"); + it('should compile a single sass file', function(done) { + var sassFile = createVinyl('mixins.scss'); var stream = sass(); - stream.on("data", function(cssFile) { + stream.on('data', function(cssFile) { should.exist(cssFile); should.exist(cssFile.path); should.exist(cssFile.relative); @@ -59,21 +67,21 @@ describe("gulp-sass", function() { stream.write(sassFile); }); - it("should compile multiple sass files", function(done) { + it('should compile multiple sass files', function(done) { var files = [ createVinyl('mixins.scss'), createVinyl('variables.scss') ]; var stream = sass(); var mustSee = files.length; + var expectedPath = 'expected/mixins.css'; - stream.on("data", function(cssFile) { + stream.on('data', function(cssFile) { should.exist(cssFile); should.exist(cssFile.path); should.exist(cssFile.relative); should.exist(cssFile.contents); - var expectedPath = 'expected/mixins.css'; - if (cssFile.path.indexOf("variables") !== -1) { + if (cssFile.path.indexOf('variables') !== -1) { expectedPath = 'expected/variables.css'; } String(cssFile.contents).should.equal( @@ -90,10 +98,10 @@ describe("gulp-sass", function() { }); }); - it("should compile files with partials in another folder", function(done) { - var sassFile = createVinyl("inheritance.scss"); + it('should compile files with partials in another folder', function(done) { + var sassFile = createVinyl('inheritance.scss'); var stream = sass(); - stream.on("data", function(cssFile) { + stream.on('data', function(cssFile) { should.exist(cssFile); should.exist(cssFile.path); should.exist(cssFile.relative); @@ -106,19 +114,19 @@ describe("gulp-sass", function() { stream.write(sassFile); }); - it("should handle sass errors", function(done) { - var errorFile = createVinyl("error.scss"); + it('should handle sass errors', function(done) { + var errorFile = createVinyl('error.scss'); var stream = sass(); - stream.on("error", function(err) { + stream.on('error', function(err) { err.message.indexOf('property "font" must be followed by a \':\'').should.equal(0); done(); }); stream.write(errorFile); }); - it("should work with gulp-sourcemaps", function(done) { - var sassFile = createVinyl("inheritance.scss"); + it('should work with gulp-sourcemaps', function(done) { + var sassFile = createVinyl('inheritance.scss'); // Expected sources are relative to file.base var expectedSources = [ @@ -126,22 +134,23 @@ describe("gulp-sass", function() { 'inheritance.scss' ]; + var stream; + sassFile.sourceMap = '{' + '"version": 3,' + - '"file": "scss/inheritance.scss",' + + '"file": "scss/subdir/multilevelimport.scss",' + '"names": [],' + '"mappings": "",' + - '"sources": [ "scss/inheritance.scss" ],' + - '"sourcesContent": [ "@import includes/cats;" ]' + + '"sources": [ "scss/subdir/multilevelimport.scss" ],' + + '"sourcesContent": [ "@import ../inheritance;" ]' + '}'; - var stream = sass(); - stream.on("data", function(cssFile) { + stream = sass(); + stream.on('data', function(cssFile) { should.exist(cssFile.sourceMap); assert.deepEqual(cssFile.sourceMap.sources, expectedSources); done(); }); stream.write(sassFile); - }); }); From 16e6077cc24f67b3774384298d23ef69c580c814 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 06:05:36 -0500 Subject: [PATCH 11/48] Updated Changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3f5a35..630d56b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# Gulp Sass Changelog + +## v2.0.0 +### March 24, 2015 +* **Change** Updated to `node-sass` 3.0.0-alpha.1 +* **New** Added support for `gulp-sourcemaps` including tests +* **New** Added `.editorconfig` for development consistency +* **New** Added linting and test for said linting + ### 1.3.3 * updated to node-sass 2.0 (final) From 3adb373c69b91e70b1cc0f08fb5e938ea1581374 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 06:32:14 -0500 Subject: [PATCH 12/48] Updated Changelog and README --- CHANGELOG.md | 1 + README.md | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 630d56b..fb5f382 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * **New** Added support for `gulp-sourcemaps` including tests * **New** Added `.editorconfig` for development consistency * **New** Added linting and test for said linting +* **Change** Updated the README ### 1.3.3 diff --git a/README.md b/README.md index 6c82a0a..1da61e5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,6 @@ -[![Build Status](https://travis-ci.org/dlmanning/gulp-sass.svg?branch=master)](https://travis-ci.org/dlmanning/gulp-sass) +# gulp-sass [![Build Status](https://travis-ci.org/dlmanning/gulp-sass.svg?branch=master)](https://travis-ci.org/dlmanning/gulp-sass) [![Join the chat at https://gitter.im/dlmanning/gulp-sass](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dlmanning/gulp-sass?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -gulp-sass -========= - -[![Join the chat at https://gitter.im/dlmanning/gulp-sass](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dlmanning/gulp-sass?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -Sass plugin for [gulp](https://github.com/gulpjs/gulp). +Sass plugin for [Gulp](https://github.com/gulpjs/gulp). # Install @@ -31,9 +26,9 @@ gulp.task('sass', function () { Options passed as a hash into `sass()` will be passed along to [`node-sass`](https://github.com/sass/node-sass). -## Source Maps TODO +## Source Maps -gulp-sass can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the SASS to CSS compilation. You will need to initialize [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) prior to running the gulp-sass compiler and write the source maps after. +`gulp-sass` can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the Sass to CSS compilation. You will need to initialize [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) prior to running `gulp-sass` and write the source maps after. ```javascript var sourcemaps = require('gulp-sourcemaps'); @@ -43,8 +38,6 @@ gulp.src('./scss/*.scss') .pipe(sass()) .pipe(sourcemaps.write()) .pipe(gulp.dest('./css')); - -// will write the source maps inline in the compiled CSS files ``` By default, [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a relative file path in the `sourcemaps.write()` function. @@ -57,10 +50,14 @@ gulp.src('./scss/*.scss') .pipe(sass()) .pipe(sourcemaps.write('./maps')) .pipe(gulp.dest('./css')); - -// will write the source maps to ./dest/css/maps ``` # Issues -Before submitting an issue, please understand that gulp-sass is only a wrapper for [node-sass](https://github.com/sass/node-sass), which in turn is a node front end for [libsass](https://github.com/sass/libsass). Missing sass features and errors should not be reported here. +`gulp-sass` is a very light-weight wrapper around [`node-sass`](https://github.com/sass/node-sass), which in turn is a Node binding for [`libsass`](https://github.com/sass/libsass), which in turn is a port of [`Sass`](https://github.com/sass/sass). Because of this, the issue you're having likely isn't a `gulp-sass` issue, but an issue with one of those three projects. + +If you have a feature request/question how Sass works/concerns on how your Sass gets compiled/errors in your compiling, it's likely a `libsass` or `Sass` issue and you should file your issue with one of those projects. + +If you're having problems with the options you're passing in, it's likely a `node-sass` or `libsass` issued and you should file your issue with one of those projects. + +We may, in the course of resolving issues, direct you to one of these other projects. If we do so, please follow up by searching that project's issue queue (both open and closed) for your problem and, if it doesn't exist, filing an issue with them. From c7e57b863cdf7f2b195de52dcebd1fd452014ded Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 06:33:11 -0500 Subject: [PATCH 13/48] Removed gulp-sourcemaps from dependencies --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 7d7a8ff..6bf39a5 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ }, "devDependencies": { "eslint": "^0.17.1", - "gulp-sourcemaps": "^1.5.1", "jshint": "^2.6.3", "mocha": "^2.2.1", "should": "^5.2.0" From 42b8d28e84c5a16cb9024248079268e952f649ac Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 06:43:42 -0500 Subject: [PATCH 14/48] Alpha 1 version, not full version --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb5f382..de968b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Gulp Sass Changelog -## v2.0.0 +## v2.0.0-alpha.1 ### March 24, 2015 * **Change** Updated to `node-sass` 3.0.0-alpha.1 * **New** Added support for `gulp-sourcemaps` including tests diff --git a/package.json b/package.json index 6bf39a5..53139c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-sass", - "version": "2.0.0", + "version": "2.0.0-alpha.1", "description": "Gulp plugin for sass", "main": "index.js", "scripts": { From 212e221212dfeb02efdf8dc4f25b3a604072bb2f Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 24 Mar 2015 12:15:21 +0000 Subject: [PATCH 15/48] Sourcemap paths seem to be relative now? At least the test still pass and paths looks the same with and without the relative fudge. Sourcemaps are completely wonky though and do not point at the right thing Also removes jshint since it's using eslint now --- index.js | 16 +--------------- package.json | 3 +-- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 5e6c871..6cf4b8a 100644 --- a/index.js +++ b/index.js @@ -40,23 +40,9 @@ module.exports = function(options) { )); } - // Build Source Maps! if (obj.map) { - // libsass gives us sources' paths relative to file; - // gulp-sourcemaps needs sources' paths relative to file.base; - // so alter the sources' paths to please gulp-sourcemaps. - obj.map = JSON.parse(obj.map.toString()); - - if (obj.map.sources) { - obj.map.sources = obj.map.sources.map(function(source) { - var abs = path.resolve(path.dirname(file.path), source); - return path.relative(file.base, abs); - }); - - obj.map = JSON.stringify(obj.map); - applySourceMap(file, obj.map); + applySourceMap(file, JSON.parse(obj.map.toString())); } - } file.contents = obj.css; file.path = gutil.replaceExtension(file.path, '.css'); diff --git a/package.json b/package.json index 53139c9..47e6338 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Gulp plugin for sass", "main": "index.js", "scripts": { - "test": "./node_modules/.bin/jshint index.js && ./node_modules/.bin/mocha test" + "test": "./node_modules/.bin/mocha test" }, "repository": { "type": "git", @@ -29,7 +29,6 @@ }, "devDependencies": { "eslint": "^0.17.1", - "jshint": "^2.6.3", "mocha": "^2.2.1", "should": "^5.2.0" } From eca922cb2d7ce2b0f109eff2039a17cf4bb9a38f Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 07:32:46 -0500 Subject: [PATCH 16/48] Nicer function for logging errors --- index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5e6c871..e78b25d 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,10 @@ var applySourceMap = require('vinyl-sourcemaps-apply'); var PLUGIN_NAME = 'gulp-sass'; -module.exports = function(options) { +////////////////////////////// +// Main Gulp Sass function +////////////////////////////// +var gulpSass = function gulpSass(options) { 'use strict'; return through.obj(function(file, enc, cb) { @@ -36,10 +39,9 @@ module.exports = function(options) { callback = function(error, obj) { if (error) { return cb(new gutil.PluginError( - PLUGIN_NAME, error.message + ' on line ' + error.line + ' in ' + error.file + PLUGIN_NAME, error.message + '\nLine ' + gutil.colors.cyan(error.line) + ' in ' + gutil.colors.magenta(error.file) )); } - // Build Source Maps! if (obj.map) { // libsass gives us sources' paths relative to file; @@ -67,3 +69,14 @@ module.exports = function(options) { sass.render(opts, callback); }); }; + +////////////////////////////// +// Log errors nicely +////////////////////////////// +gulpSass.logError = function logError(error) { + 'use strict'; + + gutil.log(gutil.colors.red('Error: ') + error.message); +}; + +module.exports = gulpSass; From 6754f39c4e230df882935e1332ba365323f0e5af Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 07:33:23 -0500 Subject: [PATCH 17/48] Updated Changelog/Readme --- CHANGELOG.md | 1 + README.md | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de968b2..99dffd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * **New** Added `.editorconfig` for development consistency * **New** Added linting and test for said linting * **Change** Updated the README +* **New** `logError` function to make streaming errors possible instead of breaking the stream ### 1.3.3 diff --git a/README.md b/README.md index 1da61e5..5867f90 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,14 @@ var sass = require('gulp-sass'); gulp.task('sass', function () { gulp.src('./scss/*.scss') - .pipe(sass().on('error', gutil.log)) + .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('./css')); }); ``` -Options passed as a hash into `sass()` will be passed along to [`node-sass`](https://github.com/sass/node-sass). +## Options + +Pass in options just like you would for [`node-sass`](https://github.com/sass/node-sass#options); they will be passed along just as if you were using `node-sass`. ## Source Maps From 5fbbc32bd96487a1858671a5bbaa30bad972b05d Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 24 Mar 2015 15:15:54 -0400 Subject: [PATCH 18/48] Updated error message to more closely match 1.x --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e78b25d..4de3dcd 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ var gulpSass = function gulpSass(options) { callback = function(error, obj) { if (error) { return cb(new gutil.PluginError( - PLUGIN_NAME, error.message + '\nLine ' + gutil.colors.cyan(error.line) + ' in ' + gutil.colors.magenta(error.file) + PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) )); } // Build Source Maps! @@ -76,7 +76,7 @@ var gulpSass = function gulpSass(options) { gulpSass.logError = function logError(error) { 'use strict'; - gutil.log(gutil.colors.red('Error: ') + error.message); + gutil.log(gutil.colors.red('[gulp-sass] ') + error.message); }; module.exports = gulpSass; From d77ca081c48b5b9a590f8db7add370c47a21e304 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 25 Mar 2015 19:29:30 +0000 Subject: [PATCH 19/48] Use plugin name const in logError --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 8a9f515..ee4eabf 100644 --- a/index.js +++ b/index.js @@ -63,7 +63,7 @@ var gulpSass = function gulpSass(options) { gulpSass.logError = function logError(error) { 'use strict'; - gutil.log(gutil.colors.red('[gulp-sass] ') + error.message); + gutil.log(gutil.colors.red('[' + PLUGIN_NAME + '] ') + error.message); }; module.exports = gulpSass; From 8bc76e15e6a135647159b5c6e665c5ce011322f1 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 26 Mar 2015 19:15:59 -0400 Subject: [PATCH 20/48] Moved 'use strict' in index.js to global Updated tests accordingly --- index.js | 6 ++---- test/lint.js | 13 +------------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 8a9f515..c32969a 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +'use strict'; + var gutil = require('gulp-util'); var through = require('through2'); var assign = require('object-assign'); @@ -11,8 +13,6 @@ var PLUGIN_NAME = 'gulp-sass'; // Main Gulp Sass function ////////////////////////////// var gulpSass = function gulpSass(options) { - 'use strict'; - return through.obj(function(file, enc, cb) { var opts, callback; @@ -61,8 +61,6 @@ var gulpSass = function gulpSass(options) { // Log errors nicely ////////////////////////////// gulpSass.logError = function logError(error) { - 'use strict'; - gutil.log(gutil.colors.red('[gulp-sass] ') + error.message); }; diff --git a/test/lint.js b/test/lint.js index a744f18..ba58856 100644 --- a/test/lint.js +++ b/test/lint.js @@ -10,11 +10,6 @@ var report; describe('code style guide', function() { it('index.js should follow our lint style guide', function(done) { - cli = new eslint.CLIEngine({ - 'rules': { - 'strict': [ 2, 'function' ] - } - }); report = cli.executeOnFiles(['index.js']); if (report.errorCount > 0 || report.warningCount > 0) { console.log(formatter(report.results)); @@ -26,11 +21,6 @@ describe('code style guide', function() { }); it('test/main.js should follow our lint style guide', function(done) { - cli = new eslint.CLIEngine({ - 'rules': { - 'strict': [ 2, 'global' ] - } - }); report = cli.executeOnFiles(['test/main.js']); if (report.errorCount > 0 || report.warningCount > 0) { console.log(formatter(report.results)); @@ -44,8 +34,7 @@ describe('code style guide', function() { it('test/lint.js should follow our lint style guide', function(done) { cli = new eslint.CLIEngine({ 'rules': { - 'no-console': 0, - 'strict': [ 2, 'global' ] + 'no-console': 0 } }); report = cli.executeOnFiles(['test/lint.js']); From c1d2696a3bebb2251b1aba23f1fcb0e00c2b4476 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 26 Mar 2015 19:40:09 -0400 Subject: [PATCH 21/48] Sync tests --- test/main.js | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 137 insertions(+), 1 deletion(-) diff --git a/test/main.js b/test/main.js index df4f8c6..c47db60 100644 --- a/test/main.js +++ b/test/main.js @@ -19,7 +19,7 @@ var createVinyl = function createVinyl(filename, contents) { }); }; -describe('gulp-sass', function() { +describe('gulp-sass -- async compile', function() { it('should pass file when it isNull()', function(done) { var stream = sass(); var emptyFile = { @@ -154,3 +154,139 @@ describe('gulp-sass', function() { stream.write(sassFile); }); }); + +describe('gulp-sass -- sync compile', function() { + it('should pass file when it isNull()', function(done) { + var stream = sass.sync(); + var emptyFile = { + 'isNull': function () { + return true; + } + }; + stream.on('data', function(data) { + data.should.equal(emptyFile); + done(); + }); + stream.write(emptyFile); + }); + + it('should emit error when file isStream()', function (done) { + var stream = sass.sync(); + var streamFile = { + 'isNull': function () { + return false; + }, + 'isStream': function () { + return true; + } + }; + stream.on('error', function(err) { + err.message.should.equal('Streaming not supported'); + done(); + }); + stream.write(streamFile); + }); + + it('should compile a single sass file', function(done) { + var sassFile = createVinyl('mixins.scss'); + var stream = sass.sync(); + stream.on('data', function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8') + ); + done(); + }); + stream.write(sassFile); + }); + + it('should compile multiple sass files', function(done) { + var files = [ + createVinyl('mixins.scss'), + createVinyl('variables.scss') + ]; + var stream = sass.sync(); + var mustSee = files.length; + var expectedPath = 'expected/mixins.css'; + + stream.on('data', function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + if (cssFile.path.indexOf('variables') !== -1) { + expectedPath = 'expected/variables.css'; + } + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, expectedPath), 'utf8') + ); + mustSee--; + if (mustSee <= 0) { + done(); + } + }); + + files.forEach(function (file) { + stream.write(file); + }); + }); + + it('should compile files with partials in another folder', function(done) { + var sassFile = createVinyl('inheritance.scss'); + var stream = sass.sync(); + stream.on('data', function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, 'expected/inheritance.css'), 'utf8') + ); + done(); + }); + stream.write(sassFile); + }); + + it('should handle sass errors', function(done) { + var errorFile = createVinyl('error.scss'); + var stream = sass.sync(); + + stream.on('error', function(err) { + err.message.indexOf('property "font" must be followed by a \':\'').should.equal(0); + done(); + }); + stream.write(errorFile); + }); + + it('should work with gulp-sourcemaps', function(done) { + var sassFile = createVinyl('inheritance.scss'); + + // Expected sources are relative to file.base + var expectedSources = [ + 'includes/_cats.scss', + 'inheritance.scss' + ]; + + var stream; + + sassFile.sourceMap = '{' + + '"version": 3,' + + '"file": "scss/subdir/multilevelimport.scss",' + + '"names": [],' + + '"mappings": "",' + + '"sources": [ "scss/subdir/multilevelimport.scss" ],' + + '"sourcesContent": [ "@import ../inheritance;" ]' + + '}'; + + stream = sass.sync(); + stream.on('data', function(cssFile) { + should.exist(cssFile.sourceMap); + assert.deepEqual(cssFile.sourceMap.sources, expectedSources); + done(); + }); + stream.write(sassFile); + }); +}); From f416379458c1c6bf5df28f7aafa3fb481a5e871a Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 26 Mar 2015 19:42:14 -0400 Subject: [PATCH 22/48] Added Sync option Addes `sass.sync` to allow users to compile synchronously. Wrapped the async callback in an `if` statement controlled by a `sync` option for the main function Added `renderSync` render option --- index.js | 62 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index c32969a..98dda5b 100644 --- a/index.js +++ b/index.js @@ -12,10 +12,11 @@ var PLUGIN_NAME = 'gulp-sass'; ////////////////////////////// // Main Gulp Sass function ////////////////////////////// -var gulpSass = function gulpSass(options) { +var gulpSass = function gulpSass(options, sync) { return through.obj(function(file, enc, cb) { var opts, - callback; + callback, + result; if (file.isNull()) { return cb(null, file); @@ -36,27 +37,56 @@ var gulpSass = function gulpSass(options) { opts.omitSourceMapUrl = true; } - callback = function(error, obj) { - if (error) { + if (sync !== true) { + callback = function(error, obj) { + if (error) { + return cb(new gutil.PluginError( + PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) + )); + } + // Build Source Maps! + if (obj.map) { + applySourceMap(file, JSON.parse(obj.map.toString())); + } + + file.contents = obj.css; + file.path = gutil.replaceExtension(file.path, '.css'); + + cb(null, file); + }; + + sass.render(opts, callback); + } + else { + try { + result = sass.renderSync(opts); + + // Build Source Maps! + if (result.map) { + applySourceMap(file, JSON.parse(result.map.toString())); + } + + file.contents = result.css; + file.path = gutil.replaceExtension(file.path, '.css'); + + cb(null, file); + } + catch(error) { return cb(new gutil.PluginError( PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) )); } - // Build Source Maps! - if (obj.map) { - applySourceMap(file, JSON.parse(obj.map.toString())); - } - - file.contents = obj.css; - file.path = gutil.replaceExtension(file.path, '.css'); - - cb(null, file); - }; - - sass.render(opts, callback); + } }); }; +////////////////////////////// +// Sync Sass render +////////////////////////////// +gulpSass.sync = function sync(options) { + return gulpSass(options, true); +}; + ////////////////////////////// // Log errors nicely ////////////////////////////// From 0d52eb31ea4ff025f0b72cbb5029667117281a0c Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 26 Mar 2015 19:44:46 -0400 Subject: [PATCH 23/48] Updated CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99dffd1..0fc5da4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Gulp Sass Changelog ## v2.0.0-alpha.1 +### March 26, 2015 +* **New** Added `renderSync` option that can be used through `sass.sync()` + ### March 24, 2015 * **Change** Updated to `node-sass` 3.0.0-alpha.1 * **New** Added support for `gulp-sourcemaps` including tests From 7684cf165ab5e75ba6b571c087edd19c2c47acd0 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 26 Mar 2015 19:48:19 -0400 Subject: [PATCH 24/48] Added sync documentation --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5867f90..44dba3f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ npm install gulp-sass --save-dev # Basic Usage -Something like this: +Something like this will compile your Sass files: ```javascript var gulp = require('gulp'); @@ -24,6 +24,20 @@ gulp.task('sass', function () { }); ``` +You can also compile synchronously, doing something like this: + +```javascript +var gulp = require('gulp'); +var gutil = require('gulp-util'); +var sass = require('gulp-sass'); + +gulp.task('sass', function () { + gulp.src('./scss/*.scss') + .pipe(sass.sync().on('error', sass.logError)) + .pipe(gulp.dest('./css')); +}); +``` + ## Options Pass in options just like you would for [`node-sass`](https://github.com/sass/node-sass#options); they will be passed along just as if you were using `node-sass`. From ebe2646a2eb320ae38442704ff74e6ca99090b3e Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 26 Mar 2015 19:50:02 -0400 Subject: [PATCH 25/48] More accurate sourcemap documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44dba3f..966ea35 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ gulp.src('./scss/*.scss') .pipe(gulp.dest('./css')); ``` -By default, [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a relative file path in the `sourcemaps.write()` function. +By default, [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a path relative to the `gulp.dest()` destination in the `sourcemaps.write()` function. ```javascript var sourcemaps = require('gulp-sourcemaps'); From ca990d098170fc79e7430511716cdbadd13666ee Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 26 Mar 2015 20:19:33 -0400 Subject: [PATCH 26/48] DRY'ed out the push back into the stream --- index.js | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index 6b0ba6e..ee7dc15 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ var PLUGIN_NAME = 'gulp-sass'; var gulpSass = function gulpSass(options, sync) { return through.obj(function(file, enc, cb) { var opts, + filePush, callback, result; @@ -37,39 +38,44 @@ var gulpSass = function gulpSass(options, sync) { opts.omitSourceMapUrl = true; } + ////////////////////////////// + // Handles returning the file to the stream + ////////////////////////////// + filePush = function filePush(sassObj) { + // Build Source Maps! + if (sassObj.map) { + applySourceMap(file, JSON.parse(sassObj.map.toString())); + } + + file.contents = sassObj.css; + file.path = gutil.replaceExtension(file.path, '.css'); + + cb(null, file); + }; + if (sync !== true) { + ////////////////////////////// + // Async Sass render + ////////////////////////////// callback = function(error, obj) { if (error) { return cb(new gutil.PluginError( PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) )); } - // Build Source Maps! - if (obj.map) { - applySourceMap(file, JSON.parse(obj.map.toString())); - } - - file.contents = obj.css; - file.path = gutil.replaceExtension(file.path, '.css'); - - cb(null, file); + filePush(obj); }; sass.render(opts, callback); } else { + ////////////////////////////// + // Sync Sass render + ////////////////////////////// try { result = sass.renderSync(opts); - // Build Source Maps! - if (result.map) { - applySourceMap(file, JSON.parse(result.map.toString())); - } - - file.contents = result.css; - file.path = gutil.replaceExtension(file.path, '.css'); - - cb(null, file); + filePush(result); } catch(error) { return cb(new gutil.PluginError( From 140c1ebecf27d23f8bbb3b8328e716388f153bc0 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Mon, 30 Mar 2015 08:11:00 -0400 Subject: [PATCH 27/48] Test should be that error is there, not that it is start of string --- test/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/main.js b/test/main.js index c47db60..ebec4e1 100644 --- a/test/main.js +++ b/test/main.js @@ -119,7 +119,7 @@ describe('gulp-sass -- async compile', function() { var stream = sass(); stream.on('error', function(err) { - err.message.indexOf('property "font" must be followed by a \':\'').should.equal(0); + err.message.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1); done(); }); stream.write(errorFile); @@ -255,7 +255,7 @@ describe('gulp-sass -- sync compile', function() { var stream = sass.sync(); stream.on('error', function(err) { - err.message.indexOf('property "font" must be followed by a \':\'').should.equal(0); + err.message.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1); done(); }); stream.write(errorFile); From 5c1478922811d6da87519b276ab01ff537de0802 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Mon, 30 Mar 2015 08:16:04 -0400 Subject: [PATCH 28/48] Updated Message style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aligns with Stylish reporter (used in ESLint, jshint-stylish, etc… Removed colors from message except for which is a standard Gulp log output color Includes line and column in error report --- index.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index ee7dc15..fd9cf8a 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ var gulpSass = function gulpSass(options, sync) { return through.obj(function(file, enc, cb) { var opts, filePush, + errorM, callback, result; @@ -53,15 +54,29 @@ var gulpSass = function gulpSass(options, sync) { cb(null, file); }; + ////////////////////////////// + // Handles error message + ////////////////////////////// + errorM = function errorM(error) { + var relativePath = path.relative(process.cwd(), error.file), + message = ''; + + message += gutil.colors.underline(relativePath) + '\n'; + message += gutil.colors.gray(' ' + error.line + ':' + error.column) + ' '; + message += error.message; + + return cb(new gutil.PluginError( + PLUGIN_NAME, message + )); + }; + if (sync !== true) { ////////////////////////////// // Async Sass render ////////////////////////////// callback = function(error, obj) { if (error) { - return cb(new gutil.PluginError( - PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) - )); + return errorM(error); } filePush(obj); }; @@ -78,9 +93,7 @@ var gulpSass = function gulpSass(options, sync) { filePush(result); } catch(error) { - return cb(new gutil.PluginError( - PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) - )); + return errorM(error); } } }); From e0ef731c39b2388ca0c7c83811a59e5f9643ea39 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Mon, 30 Mar 2015 09:54:24 -0400 Subject: [PATCH 29/48] Removed from the examples as logging is now done through --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 966ea35..8c4c374 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ Something like this will compile your Sass files: ```javascript var gulp = require('gulp'); -var gutil = require('gulp-util'); var sass = require('gulp-sass'); gulp.task('sass', function () { @@ -28,7 +27,6 @@ You can also compile synchronously, doing something like this: ```javascript var gulp = require('gulp'); -var gutil = require('gulp-util'); var sass = require('gulp-sass'); gulp.task('sass', function () { From 9c0e76fc8b208a747cdac1731609b74981cf9dac Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 24 Mar 2015 22:36:26 +0000 Subject: [PATCH 30/48] Add tests for sass+scss syntax --- test/expected/indent.css | 3 +++ test/main.js | 47 ++++++++++++++++++++++++++++++++++++++++ test/scss/indent.sass | 3 +++ 3 files changed, 53 insertions(+) create mode 100644 test/expected/indent.css create mode 100644 test/scss/indent.sass diff --git a/test/expected/indent.css b/test/expected/indent.css new file mode 100644 index 0000000..14b8030 --- /dev/null +++ b/test/expected/indent.css @@ -0,0 +1,3 @@ +#main { + color: blue; + font-size: 0.3em; } diff --git a/test/main.js b/test/main.js index ebec4e1..15914f3 100644 --- a/test/main.js +++ b/test/main.js @@ -153,6 +153,53 @@ describe('gulp-sass -- async compile', function() { }); stream.write(sassFile); }); + + it('should compile a single indented sass file', function(done) { + var sassFile = createVinyl('indent.sass'); + var stream = sass(); + stream.on('data', function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, 'expected/indent.css'), 'utf8') + ); + done(); + }); + stream.write(sassFile); + }); + + it('should parse files in sass and scss', function(done) { + var files = [ + createVinyl('mixins.scss'), + createVinyl('indent.sass') + ]; + var stream = sass(); + var mustSee = files.length; + var expectedPath = 'expected/mixins.css'; + + stream.on('data', function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + if (cssFile.path.indexOf('indent') !== -1) { + expectedPath = 'expected/indent.css'; + } + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, expectedPath), 'utf8') + ); + mustSee--; + if (mustSee <= 0) { + done(); + } + }); + + files.forEach(function (file) { + stream.write(file); + }); + }); }); describe('gulp-sass -- sync compile', function() { diff --git a/test/scss/indent.sass b/test/scss/indent.sass new file mode 100644 index 0000000..e854b5c --- /dev/null +++ b/test/scss/indent.sass @@ -0,0 +1,3 @@ +#main + color: blue + font-size: 0.3em From 25ee16f9d633f9c4e609d7cde82db67c3ef72054 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 25 Mar 2015 19:41:22 +0000 Subject: [PATCH 31/48] Replace indent.sass to match an existing issue https://github.com/dlmanning/gulp-sass/issues/187 was failing on 1.x --- test/expected/indent.css | 5 ++--- test/scss/indent.sass | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/expected/indent.css b/test/expected/indent.css index 14b8030..39efa47 100644 --- a/test/expected/indent.css +++ b/test/expected/indent.css @@ -1,3 +1,2 @@ -#main { - color: blue; - font-size: 0.3em; } +body .div { + color: blue; } diff --git a/test/scss/indent.sass b/test/scss/indent.sass index e854b5c..1c72199 100644 --- a/test/scss/indent.sass +++ b/test/scss/indent.sass @@ -1,3 +1,4 @@ -#main - color: blue - font-size: 0.3em +$color: blue + +body .div + color: $color From de6af93958d17e825d7cf9dd6b10864aa06b0ddb Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 25 Mar 2015 19:49:52 +0000 Subject: [PATCH 32/48] Add a sass file to the inheritance test --- test/expected/inheritance.css | 3 +++ test/main.js | 4 ++-- test/scss/includes/_dogs.sass | 5 +++++ test/scss/inheritance.scss | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/scss/includes/_dogs.sass diff --git a/test/expected/inheritance.css b/test/expected/inheritance.css index d2c002a..62fc9a3 100644 --- a/test/expected/inheritance.css +++ b/test/expected/inheritance.css @@ -1,6 +1,9 @@ body { background: pink; } +footer { + background: red; } + .error, .badError { border: #f00; background: #fdd; } diff --git a/test/main.js b/test/main.js index 15914f3..c187d89 100644 --- a/test/main.js +++ b/test/main.js @@ -5,7 +5,6 @@ var gutil = require('gulp-util'); var path = require('path'); var fs = require('fs'); var sass = require('../index'); -var assert = require('assert'); var createVinyl = function createVinyl(filename, contents) { var base = path.join(__dirname, 'scss'); @@ -131,6 +130,7 @@ describe('gulp-sass -- async compile', function() { // Expected sources are relative to file.base var expectedSources = [ 'includes/_cats.scss', + 'includes/_dogs.sass', 'inheritance.scss' ]; @@ -148,7 +148,7 @@ describe('gulp-sass -- async compile', function() { stream = sass(); stream.on('data', function(cssFile) { should.exist(cssFile.sourceMap); - assert.deepEqual(cssFile.sourceMap.sources, expectedSources); + cssFile.sourceMap.sources.should.eql(expectedSources); done(); }); stream.write(sassFile); diff --git a/test/scss/includes/_dogs.sass b/test/scss/includes/_dogs.sass new file mode 100644 index 0000000..fbdee6e --- /dev/null +++ b/test/scss/includes/_dogs.sass @@ -0,0 +1,5 @@ +$blue: #3bbfce; +$margin: 16px; + +footer + background: red; diff --git a/test/scss/inheritance.scss b/test/scss/inheritance.scss index f42ec79..b2cab38 100644 --- a/test/scss/inheritance.scss +++ b/test/scss/inheritance.scss @@ -1,4 +1,5 @@ @import "includes/cats"; +@import "includes/dogs"; .error { border: #f00; From 5c7777fda931d8eb5711e698b52d1080834fe62a Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 31 Mar 2015 15:44:22 +0100 Subject: [PATCH 33/48] Rebase on top of 2.x --- test/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/main.js b/test/main.js index c187d89..8dc6522 100644 --- a/test/main.js +++ b/test/main.js @@ -314,6 +314,7 @@ describe('gulp-sass -- sync compile', function() { // Expected sources are relative to file.base var expectedSources = [ 'includes/_cats.scss', + 'includes/_dogs.sass', 'inheritance.scss' ]; @@ -331,7 +332,7 @@ describe('gulp-sass -- sync compile', function() { stream = sass.sync(); stream.on('data', function(cssFile) { should.exist(cssFile.sourceMap); - assert.deepEqual(cssFile.sourceMap.sources, expectedSources); + cssFile.sourceMap.sources.should.eql(expectedSources); done(); }); stream.write(sassFile); From 3cdf1a325dca5f7ac7d9f6150d74d16dee780950 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 31 Mar 2015 15:55:26 -0400 Subject: [PATCH 34/48] Passing file as data Resolves dlmanning/gulp-sass#158 once I get it working --- index.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fd9cf8a..1e32f00 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ var PLUGIN_NAME = 'gulp-sass'; var gulpSass = function gulpSass(options, sync) { return through.obj(function(file, enc, cb) { var opts, + ip, filePush, errorM, callback, @@ -31,7 +32,20 @@ var gulpSass = function gulpSass(options, sync) { } opts = assign({}, options); - opts.file = file.path; + opts.data = file.contents.toString(); + + if (opts.includePaths) { + if (typeof opts.includePaths === 'string') { + ip = opts.includePaths; + opts.includePaths = []; + opts.includePaths.push(ip); + } + } + else { + opts.includePaths = []; + } + + opts.includePaths.push(path.dirname(file.path)); // Generate Source Maps if plugin source-map present if (file.sourceMap) { @@ -58,9 +72,13 @@ var gulpSass = function gulpSass(options, sync) { // Handles error message ////////////////////////////// errorM = function errorM(error) { - var relativePath = path.relative(process.cwd(), error.file), + var relativePath = '', + filePath = error.file === 'stdin' ? file.path : error.file, message = ''; + filePath = filePath ? filePath : file.path; + relativePath = path.relative(process.cwd(), filePath); + message += gutil.colors.underline(relativePath) + '\n'; message += gutil.colors.gray(' ' + error.line + ':' + error.column) + ' '; message += error.message; From bea198e5451cd53eb16b5ccef736b108b32378e6 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 31 Mar 2015 15:56:18 -0400 Subject: [PATCH 35/48] Updated Tests --- test/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main.js b/test/main.js index ebec4e1..b1435ff 100644 --- a/test/main.js +++ b/test/main.js @@ -131,7 +131,7 @@ describe('gulp-sass -- async compile', function() { // Expected sources are relative to file.base var expectedSources = [ 'includes/_cats.scss', - 'inheritance.scss' + '../../stdin' ]; var stream; From 4c4c3c125efdb3f646ca814541447c022bbd26e8 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 31 Mar 2015 16:26:29 -0400 Subject: [PATCH 36/48] A little bit of source map massaging --- index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1e32f00..f6e9b96 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,9 @@ var gulpSass = function gulpSass(options, sync) { var opts, ip, filePush, + sassMap, + sassMapFile, + sassFileSrc, errorM, callback, result; @@ -59,7 +62,18 @@ var gulpSass = function gulpSass(options, sync) { filePush = function filePush(sassObj) { // Build Source Maps! if (sassObj.map) { - applySourceMap(file, JSON.parse(sassObj.map.toString())); + // Transform map into JSON + sassMap = JSON.parse(sassObj.map.toString()); + // Grab the stdout and transform it into stdin + sassMapFile = sassMap.file.replace('stdout', 'stdin'); + // Grab the base file name that's being worked on + sassFileSrc = file.path.split('/').pop(); + // Replace the stdin with the original file name + sassMap.sources[sassMap.sources.indexOf(sassMapFile)] = sassFileSrc; + // Replace the map file with the original file name + sassMap.file = sassFileSrc; + // Apply the map + applySourceMap(file, sassMap); } file.contents = sassObj.css; From 5b8d4eb3197fc4bd52b765bb77222b92aada15d3 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 31 Mar 2015 16:26:47 -0400 Subject: [PATCH 37/48] Nope, shouldn't be , should be file name --- test/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main.js b/test/main.js index b1435ff..ebec4e1 100644 --- a/test/main.js +++ b/test/main.js @@ -131,7 +131,7 @@ describe('gulp-sass -- async compile', function() { // Expected sources are relative to file.base var expectedSources = [ 'includes/_cats.scss', - '../../stdin' + 'inheritance.scss' ]; var stream; From 0fefd16607cdd77c101377e8468286e11c1b5880 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Wed, 1 Apr 2015 10:43:39 -0400 Subject: [PATCH 38/48] Updated vars and includePaths based on comments --- index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index f6e9b96..2bcb78e 100644 --- a/index.js +++ b/index.js @@ -15,11 +15,7 @@ var PLUGIN_NAME = 'gulp-sass'; var gulpSass = function gulpSass(options, sync) { return through.obj(function(file, enc, cb) { var opts, - ip, filePush, - sassMap, - sassMapFile, - sassFileSrc, errorM, callback, result; @@ -39,9 +35,7 @@ var gulpSass = function gulpSass(options, sync) { if (opts.includePaths) { if (typeof opts.includePaths === 'string') { - ip = opts.includePaths; - opts.includePaths = []; - opts.includePaths.push(ip); + opts.includePaths = [opts.includePaths]; } } else { @@ -60,6 +54,10 @@ var gulpSass = function gulpSass(options, sync) { // Handles returning the file to the stream ////////////////////////////// filePush = function filePush(sassObj) { + var sassMap, + sassMapFile, + sassFileSrc; + // Build Source Maps! if (sassObj.map) { // Transform map into JSON From ad6e6e4ddd10cb2b1bf86f6b4676a1970a036b6f Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Wed, 1 Apr 2015 11:07:33 -0400 Subject: [PATCH 39/48] Tests for file rename and file contents change --- test/main.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/main.js b/test/main.js index ebec4e1..108e667 100644 --- a/test/main.js +++ b/test/main.js @@ -125,6 +125,49 @@ describe('gulp-sass -- async compile', function() { stream.write(errorFile); }); + it('should compile a single sass file if the file name has been changed in the stream', function(done) { + var sassFile = createVinyl('mixins.scss'); + var stream; + + // Transform file name + sassFile.path = path.join(path.join(__dirname, 'scss'), 'mixin--changed.scss'); + + stream = sass(); + stream.on('data', function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + cssFile.path.split('/').pop().should.equal('mixin--changed.css'); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + String(cssFile.contents).should.equal( + fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8') + ); + done(); + }); + stream.write(sassFile); + }); + + it('should preserve changes made in-stream to a Sass file', function(done) { + var sassFile = createVinyl('mixins.scss'); + var stream; + + // Transform file name + sassFile.contents = new Buffer('/* Added Dynamically */' + sassFile.contents.toString()); + + stream = sass(); + stream.on('data', function(cssFile) { + should.exist(cssFile); + should.exist(cssFile.path); + should.exist(cssFile.relative); + should.exist(cssFile.contents); + String(cssFile.contents).should.equal('/* Added Dynamically */\n' + + fs.readFileSync(path.join(__dirname, 'expected/mixins.css'), 'utf8') + ); + done(); + }); + stream.write(sassFile); + }); + it('should work with gulp-sourcemaps', function(done) { var sassFile = createVinyl('inheritance.scss'); From b7ade97b7ab852e6f41f7d62c297d6cfcef11f67 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Wed, 1 Apr 2015 12:32:12 -0400 Subject: [PATCH 40/48] Indented Syntax support --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 2bcb78e..b692fac 100644 --- a/index.js +++ b/index.js @@ -33,6 +33,12 @@ var gulpSass = function gulpSass(options, sync) { opts = assign({}, options); opts.data = file.contents.toString(); + // Ensure `indentedSyntax` is true if a `.sass` file + if (path.extname(file.path) === '.sass') { + opts.indentedSyntax = true; + } + + // Ensure file's parent directory in the include path if (opts.includePaths) { if (typeof opts.includePaths === 'string') { opts.includePaths = [opts.includePaths]; From cc2f81581390481504eec3d3a2efd084ccdee043 Mon Sep 17 00:00:00 2001 From: David Manning Date: Wed, 1 Apr 2015 17:51:20 -0700 Subject: [PATCH 41/48] bump node-sass to 3.0.0-beta.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47e6338..a21502c 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "gulp-util": "^3.0", - "node-sass": "^3.0.0-alpha.1", + "node-sass": "^3.0.0-beta.4", "object-assign": "^2.0.0", "through2": "^0.6.3", "vinyl-sourcemaps-apply": "~0.1.1" From c1d629c209059ca03f18944f61afad6a0ea84b51 Mon Sep 17 00:00:00 2001 From: David Peter Date: Tue, 14 Apr 2015 12:05:34 -0400 Subject: [PATCH 42/48] Allow you to change the compiler and expose it This will let you write sass.compiler.types, for example, and access the sass types without having to require it in your main app. Additionally, this lets you use a forked compiler, or a different branch of the same compiler. --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b692fac..d546deb 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ var gutil = require('gulp-util'); var through = require('through2'); var assign = require('object-assign'); var path = require('path'); -var sass = require('node-sass'); var applySourceMap = require('vinyl-sourcemaps-apply'); var PLUGIN_NAME = 'gulp-sass'; @@ -117,14 +116,14 @@ var gulpSass = function gulpSass(options, sync) { filePush(obj); }; - sass.render(opts, callback); + gulpSass.compiler.render(opts, callback); } else { ////////////////////////////// // Sync Sass render ////////////////////////////// try { - result = sass.renderSync(opts); + result = gulpSass.compiler.renderSync(opts); filePush(result); } @@ -149,4 +148,9 @@ gulpSass.logError = function logError(error) { gutil.log(gutil.colors.red('[' + PLUGIN_NAME + '] ') + error.message); }; +////////////////////////////// +// Store compiler in a prop +////////////////////////////// +gulpSass.compiler = require('node-sass'); + module.exports = gulpSass; From 2b21a494cb25a39d322e911f73ad5c0dd9b66fb0 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 22 Apr 2015 16:50:56 +0100 Subject: [PATCH 43/48] Update to node-sass beta 7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a21502c..eec4d79 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "gulp-util": "^3.0", - "node-sass": "^3.0.0-beta.4", + "node-sass": "^3.0.0-beta.7", "object-assign": "^2.0.0", "through2": "^0.6.3", "vinyl-sourcemaps-apply": "~0.1.1" From 299c18fd0c7d9f22619ff9b6b463715d2a1e441e Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 30 Apr 2015 07:12:59 -0400 Subject: [PATCH 44/48] :memo: Add Contributing guidelines --- CONTRIBUTING.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..076047d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,71 @@ +# Contributing to Gulp Sass + +Gulp Sass is a very light-weight [Gulp](https://github.com/gulpjs/gulp) wrapper for [`node-sass`](https://github.com/sass/node-sass), which in turn is a Node binding for [`libsass`](https://github.com/sass/libsass), which in turn is a port of [`Sass`](https://github.com/sass/sass). + +## Submitting Issues + +* Before creating a new issue, perform a [cursory search](https://github.com/issues?utf8=%E2%9C%93&q=repo%3Adlmanning%2Fgulp-sass+repo%3Asass%2Fnode-sass+repo%3Asass%2Flibsass+repo%3Asass%2Fsass+repo%3Asass-eyeglass%2Feyeglass) in the Gulp Sass, Node Sass, Libsass, and main Sass repos to see if a similar issue has already been submitted. +* You can create an issue [here](https://github.com/dlmanning/gulp-sass/issues). Please include as many details as possible in your report. +* Issue titles should be descriptive, explaining at the high level what it is about. +* Please include the version of `gulp-sass` you are using. +* Do not open a [pull request](#pull-requests) to resolve an issue without first receiving feedback from a `collaborator` or `owner` and having them agree on a solution forward. +* Include screenshots and animated GIFs whenever possible; they are immensely helpful. +* Issues that have a number of sub-items that need to be complete should use [task lists](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) to track the sub-items in the main issue comment. + + +## Pull Requests + +* **DO NOT ISSUE A PULL REQUEST WITHOUT FIRST [SUBMITTING AN ISSUE](#submitting-issues)** +* Pull requests should reference their related issues. If the pull request closes an issue, [please reference its closing in your commit messages](https://help.github.com/articles/closing-issues-via-commit-messages/). Pull requests not referencing any issues will be closed. +* Pull request titles should be descriptive, explaining at the high level what it is doing, and should be written in the same style as [Git commit messages](#git-commit-messages). +* Update the `CHANGELOG` with the changes made by your pull request, making sure to use the proper [Emoji](#emoji-cheatsheet). +* Follow our JavaScript styleguides. Tests will fail if you do not. +* Ensure that you have [EditorConfig](http://editorconfig.org/) installed in your editor of choice and that it is functioning properly. +* Do not squash or rebase your commits when submitting a Pull Request. It makes it much harder to follow your work and make incremental changes. +* Update the [CHANGELOG](#maintaining-thechangelog) with your changes. +* Ensure no Emoji tags are used in the title of your Pull Request + +### Git Commit Messages + +* Use the present tense (`"Add feature"` not `"Added Feature"`) +* Use the imperative mood (`"Move cursor to…"` not `"Moves cursor to…"`) +* Limit the first line to 72 characters or less +* Include relevant Emoji from our [Emoji cheatsheet](#emoji-cheatsheet) + +### Branching Model + +* Branches must be made off of the most current `master` branch from `git@github.com:dlmanning/gulp-sass.git` +* Pull requests must be made into our [master](https://github.com/dlmanning/gulp-sass/tree/master) branch. +* The following branch prefixes should be used when creating a new branch: + * `hotfix/` - fixes a bug that got through to a live version and need to be squashed + * `feature/` - update to or new code for `gulp-sass` + * `release/` - a release of `gulp-sass` + +## Creating a New Version + +Versioning is done through [SEMVER](http://semver.org/). When creating a new version, create new release branch off of `master` with the version's name, and create a new tag with `v` prefixed with the version's name from that branch. + +For instance, if you are creating version `1.1.0`, you would start by merging `develop` into `master`, create a branch `release/1.1.0` from `master`, and create a tag `v1.1.0` from branch `release/1.1.0`. + +### Maintaining the Changelog + +The Changelog should have a list of changes made for each version. They should be organized so additions come first, changes come second, and deletions come third. Version numbers should be 2nd level headers with the `v` in front (like a tag) and the date of the version's most recent update should be underneath in italics. + +Changelog messages do not need to cover each individual commit made, but rather should have individual summaries of the changes made. Changelog messages should be written in the same style as [Git commit messages](#git-commit-messages). + +## Emoji Cheatsheet + +When creating creating commits or updating the CHANGELOG, please **start** the commit message or update with one of the following applicable Emoji. Emoji should not be used at the start of issue or pull request titles. + +* :art: `:art:` when improving the format/structure of the code +* :racehorse: `:racehorse:` when improving performance +* :memo: `:memo:` when writing long-form text (documentation, guidelines, principles, etc…) +* :bug: `:bug:` when fixing a bug +* :fire: `:fire:` when removing code or files +* :green_heart: `:green_heart:` when fixing the CI build +* :white_check_mark: `:white_check_mark:` when adding tests +* :lock: `:lock:` when dealing with security +* :arrow_up: `:arrow_up:` when upgrading dependencies +* :arrow_down: `:arrow_down:` when downgrading dependencies +* :shirt: `:shirt:` when removing linter warnings +* :shipit: `:shipit:` when creating a new release From ee07858ef462fdf5d0f746fe65dcdda0c204a980 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Thu, 30 Apr 2015 07:13:41 -0400 Subject: [PATCH 45/48] :art: Update formatting of CHANGELOG entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc5da4..0bbaacd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Gulp Sass Changelog ## v2.0.0-alpha.1 -### March 26, 2015 +**March 26, 2015** + * **New** Added `renderSync` option that can be used through `sass.sync()` ### March 24, 2015 From e072993c5596a6a1a0fef29108aa1e64d0399757 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Fri, 1 May 2015 07:58:00 -0400 Subject: [PATCH 46/48] :fire: Remove Branching Model section :memo: Lighten wording on Emoji usage --- CONTRIBUTING.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 076047d..9a448a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,23 +23,15 @@ Gulp Sass is a very light-weight [Gulp](https://github.com/gulpjs/gulp) wrapper * Ensure that you have [EditorConfig](http://editorconfig.org/) installed in your editor of choice and that it is functioning properly. * Do not squash or rebase your commits when submitting a Pull Request. It makes it much harder to follow your work and make incremental changes. * Update the [CHANGELOG](#maintaining-thechangelog) with your changes. -* Ensure no Emoji tags are used in the title of your Pull Request +* Branches should be made off of the most current `master` branch from `git@github.com:dlmanning/gulp-sass.git` +* Pull requests should be made into our [master](https://github.com/dlmanning/gulp-sass/tree/master) branch. ### Git Commit Messages * Use the present tense (`"Add feature"` not `"Added Feature"`) * Use the imperative mood (`"Move cursor to…"` not `"Moves cursor to…"`) * Limit the first line to 72 characters or less -* Include relevant Emoji from our [Emoji cheatsheet](#emoji-cheatsheet) - -### Branching Model - -* Branches must be made off of the most current `master` branch from `git@github.com:dlmanning/gulp-sass.git` -* Pull requests must be made into our [master](https://github.com/dlmanning/gulp-sass/tree/master) branch. -* The following branch prefixes should be used when creating a new branch: - * `hotfix/` - fixes a bug that got through to a live version and need to be squashed - * `feature/` - update to or new code for `gulp-sass` - * `release/` - a release of `gulp-sass` +* Consider including relevant Emoji from our [Emoji cheatsheet](#emoji-cheatsheet) ## Creating a New Version From 083e6bcb9c13ff9b56ccfd6f444a7ba7ff0f86d3 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 5 May 2015 08:56:08 -0400 Subject: [PATCH 47/48] :fire: Remove reference to branch --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a448a3..4ab9e5f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ Gulp Sass is a very light-weight [Gulp](https://github.com/gulpjs/gulp) wrapper Versioning is done through [SEMVER](http://semver.org/). When creating a new version, create new release branch off of `master` with the version's name, and create a new tag with `v` prefixed with the version's name from that branch. -For instance, if you are creating version `1.1.0`, you would start by merging `develop` into `master`, create a branch `release/1.1.0` from `master`, and create a tag `v1.1.0` from branch `release/1.1.0`. +For instance, if you are creating version `1.1.0`, you would create a branch `release/1.1.0` from `master` and create a tag `v1.1.0` from branch `release/1.1.0`. ### Maintaining the Changelog From c033adf89b1d8eedfa9345a9a00a2b9dcca13a4e Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Wed, 6 May 2015 10:31:25 -0400 Subject: [PATCH 48/48] :arrow_up: Update Node Sass to 3.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index eec4d79..57ef1f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-sass", - "version": "2.0.0-alpha.1", + "version": "2.0.0", "description": "Gulp plugin for sass", "main": "index.js", "scripts": { @@ -22,7 +22,7 @@ }, "dependencies": { "gulp-util": "^3.0", - "node-sass": "^3.0.0-beta.7", + "node-sass": "^3.0.0", "object-assign": "^2.0.0", "through2": "^0.6.3", "vinyl-sourcemaps-apply": "~0.1.1"