Skip to content

Commit 44be409

Browse files
authoredApr 5, 2018
Merge pull request #667 from dlmanning/next
Drop support for non-Active LTS and Current releases
2 parents 04fb925 + 7656eff commit 44be409

File tree

8 files changed

+380
-568
lines changed

8 files changed

+380
-568
lines changed
 

‎.eslintrc

+3-153
Original file line numberDiff line numberDiff line change
@@ -4,159 +4,9 @@ env:
44
mocha: true
55
node: true
66

7-
# globals:
8-
#########################
9-
## Only add globals if you're absolutely certain they need to be globals
10-
##########################
11-
# console: true
12-
13-
#########################
14-
## set to 0 to allow
15-
## set to 1 to disallow as warning
16-
## set to 2 to disallow as error
17-
#########################
187
rules:
19-
#########################
20-
## Optional Rules
21-
#########################
22-
# Disallow use of `console`
23-
no-console: 2
24-
25-
# Disallow warning comments
26-
no-warning-comments:
27-
- 1
28-
- terms:
29-
- todo
30-
- fixme
31-
location: anywhere
32-
33-
# Warns when variables are defined but never used
34-
no-unused-vars: 1
35-
36-
# Enforces comma style (first or last)
37-
comma-style:
38-
- 2
39-
- last
40-
41-
# Enforces one true `this` variable
42-
consistent-this:
8+
max-len:
439
- 2
44-
- self
45-
# Allows dangling underscores in identifiers
46-
no-underscore-dangle: 2
47-
48-
# Enforces function expressions to have a name
49-
func-names: 0
50-
51-
# Set maximum depth of nested callbacks
52-
max-nested-callbacks:
53-
- 1
54-
- 3
55-
56-
#########################
57-
## Core Rules
58-
##########################
59-
# Enforces camel case names
60-
camelcase: 2
61-
62-
# Prohibit use of == and != in favor of === and !==
63-
eqeqeq: 2
64-
65-
# Suppresses warnings about == null comparisons
66-
no-eq-null: 2
67-
68-
# No mixing tabs and spaces, with 2 spaces only
69-
no-mixed-spaces-and-tabs: 2
70-
71-
# Prohibits use of a variable before it is defined
72-
no-use-before-define: 2
73-
74-
# Requires capitalized names for constructor functions
75-
new-cap: 2
76-
77-
# Prohibits use of explicitly undeclared variables
78-
no-undef: 2
79-
80-
# Enforces Use Strict at the top of function scope
81-
strict:
82-
- 2
83-
- global
84-
85-
# Requires variable declarations to be at the top
86-
vars-on-top: 2
87-
88-
# Enforce curly braces around blocks in loops and conditionals
89-
curly: 2
90-
91-
# Prohibits the use of immediate function invocations w/o wrapping in parentheses
92-
wrap-iife: 2
93-
94-
# Prohibits `argument.caller` and `argument.callee`
95-
no-caller: 2
96-
97-
# Requires all `for in` loops to filter object's items
98-
guard-for-in: 2
99-
100-
# Prohibits comparing a variable against itself
101-
no-self-compare: 2
10+
- 120
10211

103-
# Prohibits use of `undefined` variable
104-
no-undefined: 0
105-
106-
# Prohibits nested ternaries
107-
no-nested-ternary: 2
108-
109-
# Enforces a space before blocks
110-
space-before-blocks:
111-
- 2
112-
- always
113-
114-
# Enforces spaces following keywords
115-
keyword-spacing:
116-
- 2
117-
- after: true
118-
119-
# Enforces quoted property names
120-
quote-props:
121-
- 2
122-
- always
123-
124-
# Enforces padded blocks
125-
padded-blocks:
126-
- 1
127-
- never
128-
129-
# Enforce functions as expressions
130-
func-style:
131-
- 2
132-
- expression
133-
134-
# Require brace style
135-
brace-style:
136-
- 2
137-
- stroustrup
138-
139-
# Prohibits Yoda conditions
140-
yoda:
141-
- 2
142-
- never
143-
144-
# Enforce use of single quotation marks for strings.
145-
quotes:
146-
- 2
147-
- single
148-
149-
# Disallow or enforce spaces inside of curly braces in objects.
150-
object-curly-spacing:
151-
- 2
152-
- always
153-
154-
# Disallow or enforce spaces inside of brackets.
155-
array-bracket-spacing:
156-
- 2
157-
- never
158-
159-
# Disallow or enforce spaces inside of computed properties.
160-
computed-property-spacing:
161-
- 2
162-
- never
12+
extends: "airbnb-base"

‎.travis.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
sudo: false
2+
13
language: node_js
4+
25
node_js:
3-
- "0.10"
4-
- node
5-
- iojs
6-
sudo: false
6+
- lts/boron
7+
- lts/carbon
8+
- current

‎README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Sass plugin for [Gulp](https://github.com/gulpjs/gulp).
44

55
**_Before filing an issue, please make sure you have [Updated to the latest Gulp Sass](https://github.com/dlmanning/gulp-sass/wiki/Update-to-the-latest-Gulp-Sass) and have gone through our [Common Issues and Their Fixes](https://github.com/dlmanning/gulp-sass/wiki/Common-Issues-and-Their-Fixes) section._**
66

7+
# Support
8+
9+
Only [Active LTS and Current releases][1] are supported.
10+
11+
[1]: https://github.com/nodejs/Release#release-schedule
12+
713
# Install
814

915
```
@@ -52,7 +58,7 @@ gulp.task('sass:watch', function () {
5258

5359
## Options
5460

55-
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`. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.
61+
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`. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.
5662

5763
For example:
5864

‎appveyor.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ platform:
1111

1212
environment:
1313
matrix:
14-
- nodejs_version: 0.10
15-
- nodejs_version: 0.12
16-
- nodejs_version: 4
17-
- nodejs_version: 6
18-
- nodejs_version: 8
19-
- nodejs_version: 9
14+
- nodejs_version: lts/boron
15+
- nodejs_version: lts/carbon
16+
- nodejs_version: current
2017

2118
install:
2219
- ps: Install-Product node $env:nodejs_version $env:platform

‎index.js

+125-150
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,158 @@
1-
'use strict';
1+
const chalk = require('chalk');
2+
const PluginError = require('plugin-error');
3+
const replaceExtension = require('replace-ext');
4+
const stripAnsi = require('strip-ansi');
5+
const through = require('through2');
6+
const clonedeep = require('lodash.clonedeep');
7+
const path = require('path');
8+
const applySourceMap = require('vinyl-sourcemaps-apply');
29

3-
var gutil = require('gulp-util');
4-
var through = require('through2');
5-
var clonedeep = require('lodash.clonedeep');
6-
var path = require('path');
7-
var applySourceMap = require('vinyl-sourcemaps-apply');
8-
9-
var PLUGIN_NAME = 'gulp-sass';
10+
const PLUGIN_NAME = 'gulp-sass';
1011

1112
//////////////////////////////
1213
// Main Gulp Sass function
1314
//////////////////////////////
14-
var gulpSass = function gulpSass(options, sync) {
15-
return through.obj(function(file, enc, cb) {
16-
var opts,
17-
filePush,
18-
errorM,
19-
callback,
20-
result;
21-
22-
if (file.isNull()) {
23-
return cb(null, file);
24-
}
25-
if (file.isStream()) {
26-
return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
27-
}
28-
if (path.basename(file.path).indexOf('_') === 0) {
29-
return cb();
30-
}
31-
if (!file.contents.length) {
32-
file.path = gutil.replaceExtension(file.path, '.css');
33-
return cb(null, file);
15+
const gulpSass = (options, sync) => through.obj((file, enc, cb) => { // eslint-disable-line consistent-return
16+
if (file.isNull()) {
17+
return cb(null, file);
18+
}
19+
20+
if (file.isStream()) {
21+
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
22+
}
23+
24+
if (path.basename(file.path).indexOf('_') === 0) {
25+
return cb();
26+
}
27+
28+
if (!file.contents.length) {
29+
file.path = replaceExtension(file.path, '.css'); // eslint-disable-line no-param-reassign
30+
return cb(null, file);
31+
}
32+
33+
const opts = clonedeep(options || {});
34+
opts.data = file.contents.toString();
35+
36+
// we set the file path here so that libsass can correctly resolve import paths
37+
opts.file = file.path;
38+
39+
// Ensure `indentedSyntax` is true if a `.sass` file
40+
if (path.extname(file.path) === '.sass') {
41+
opts.indentedSyntax = true;
42+
}
43+
44+
// Ensure file's parent directory in the include path
45+
if (opts.includePaths) {
46+
if (typeof opts.includePaths === 'string') {
47+
opts.includePaths = [opts.includePaths];
3448
}
49+
} else {
50+
opts.includePaths = [];
51+
}
52+
53+
opts.includePaths.unshift(path.dirname(file.path));
54+
55+
// Generate Source Maps if plugin source-map present
56+
if (file.sourceMap) {
57+
opts.sourceMap = file.path;
58+
opts.omitSourceMapUrl = true;
59+
opts.sourceMapContents = true;
60+
}
61+
62+
//////////////////////////////
63+
// Handles returning the file to the stream
64+
//////////////////////////////
65+
const filePush = (sassObj) => {
66+
let sassMap;
67+
let sassMapFile;
68+
let sassFileSrc;
69+
let sassFileSrcPath;
70+
let sourceFileIndex;
71+
72+
// Build Source Maps!
73+
if (sassObj.map) {
74+
// Transform map into JSON
75+
sassMap = JSON.parse(sassObj.map.toString());
76+
// Grab the stdout and transform it into stdin
77+
sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
78+
// Grab the base file name that's being worked on
79+
sassFileSrc = file.relative;
80+
// Grab the path portion of the file that's being worked on
81+
sassFileSrcPath = path.dirname(sassFileSrc);
82+
if (sassFileSrcPath) {
83+
// Prepend the path to all files in the sources array except the file that's being worked on
84+
sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
85+
sassMap.sources = sassMap.sources.map((source, index) => { // eslint-disable-line arrow-body-style
86+
return index === sourceFileIndex ? source : path.join(sassFileSrcPath, source);
87+
});
88+
}
3589

90+
// Remove 'stdin' from souces and replace with filenames!
91+
sassMap.sources = sassMap.sources.filter(src => src !== 'stdin' && src);
3692

37-
opts = clonedeep(options || {});
38-
opts.data = file.contents.toString();
93+
// Replace the map file with the original file name (but new extension)
94+
sassMap.file = replaceExtension(sassFileSrc, '.css');
95+
// Apply the map
96+
applySourceMap(file, sassMap);
97+
}
3998

40-
// we set the file path here so that libsass can correctly resolve import paths
41-
opts.file = file.path;
99+
file.contents = sassObj.css; // eslint-disable-line no-param-reassign
100+
file.path = replaceExtension(file.path, '.css'); // eslint-disable-line no-param-reassign
42101

43-
// Ensure `indentedSyntax` is true if a `.sass` file
44-
if (path.extname(file.path) === '.sass') {
45-
opts.indentedSyntax = true;
46-
}
102+
cb(null, file);
103+
};
47104

48-
// Ensure file's parent directory in the include path
49-
if (opts.includePaths) {
50-
if (typeof opts.includePaths === 'string') {
51-
opts.includePaths = [opts.includePaths];
52-
}
53-
}
54-
else {
55-
opts.includePaths = [];
56-
}
105+
//////////////////////////////
106+
// Handles error message
107+
//////////////////////////////
108+
const errorM = (error) => {
109+
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
110+
const relativePath = path.relative(process.cwd(), filePath);
111+
const message = [chalk.underline(relativePath), error.formatted].join('\n');
57112

58-
opts.includePaths.unshift(path.dirname(file.path));
113+
error.messageFormatted = message; // eslint-disable-line no-param-reassign
114+
error.messageOriginal = error.message; // eslint-disable-line no-param-reassign
115+
error.message = stripAnsi(message); // eslint-disable-line no-param-reassign
116+
error.relativePath = relativePath; // eslint-disable-line no-param-reassign
59117

60-
// Generate Source Maps if plugin source-map present
61-
if (file.sourceMap) {
62-
opts.sourceMap = file.path;
63-
opts.omitSourceMapUrl = true;
64-
opts.sourceMapContents = true;
65-
}
118+
return cb(new PluginError(PLUGIN_NAME, error));
119+
};
66120

121+
if (sync !== true) {
67122
//////////////////////////////
68-
// Handles returning the file to the stream
123+
// Async Sass render
69124
//////////////////////////////
70-
filePush = function filePush(sassObj) {
71-
var sassMap,
72-
sassMapFile,
73-
sassFileSrc,
74-
sassFileSrcPath,
75-
sourceFileIndex;
76-
77-
// Build Source Maps!
78-
if (sassObj.map) {
79-
// Transform map into JSON
80-
sassMap = JSON.parse(sassObj.map.toString());
81-
// Grab the stdout and transform it into stdin
82-
sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
83-
// Grab the base file name that's being worked on
84-
sassFileSrc = file.relative;
85-
// Grab the path portion of the file that's being worked on
86-
sassFileSrcPath = path.dirname(sassFileSrc);
87-
if (sassFileSrcPath) {
88-
// Prepend the path to all files in the sources array except the file that's being worked on
89-
sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
90-
sassMap.sources = sassMap.sources.map(function(source, index) {
91-
return (index === sourceFileIndex) ? source : path.join(sassFileSrcPath, source);
92-
});
93-
}
94-
95-
// Remove 'stdin' from souces and replace with filenames!
96-
sassMap.sources = sassMap.sources.filter(function(src) {
97-
if (src !== 'stdin') {
98-
return src;
99-
}
100-
});
101-
102-
// Replace the map file with the original file name (but new extension)
103-
sassMap.file = gutil.replaceExtension(sassFileSrc, '.css');
104-
// Apply the map
105-
applySourceMap(file, sassMap);
125+
const callback = (error, obj) => { // eslint-disable-line consistent-return
126+
if (error) {
127+
return errorM(error);
106128
}
107-
108-
file.contents = sassObj.css;
109-
file.path = gutil.replaceExtension(file.path, '.css');
110-
111-
cb(null, file);
129+
filePush(obj);
112130
};
113131

132+
gulpSass.compiler.render(opts, callback);
133+
} else {
114134
//////////////////////////////
115-
// Handles error message
135+
// Sync Sass render
116136
//////////////////////////////
117-
errorM = function errorM(error) {
118-
var relativePath = '',
119-
filePath = error.file === 'stdin' ? file.path : error.file,
120-
message = '';
121-
122-
filePath = filePath ? filePath : file.path;
123-
relativePath = path.relative(process.cwd(), filePath);
124-
125-
message += gutil.colors.underline(relativePath) + '\n';
126-
message += error.formatted;
127-
128-
error.messageFormatted = message;
129-
error.messageOriginal = error.message;
130-
error.message = gutil.colors.stripColor(message);
131-
132-
error.relativePath = relativePath;
133-
134-
return cb(new gutil.PluginError(
135-
PLUGIN_NAME, error
136-
));
137-
};
138-
139-
if (sync !== true) {
140-
//////////////////////////////
141-
// Async Sass render
142-
//////////////////////////////
143-
callback = function(error, obj) {
144-
if (error) {
145-
return errorM(error);
146-
}
147-
filePush(obj);
148-
};
149-
150-
gulpSass.compiler.render(opts, callback);
137+
try {
138+
filePush(gulpSass.compiler.renderSync(opts));
139+
} catch (error) {
140+
return errorM(error);
151141
}
152-
else {
153-
//////////////////////////////
154-
// Sync Sass render
155-
//////////////////////////////
156-
try {
157-
result = gulpSass.compiler.renderSync(opts);
158-
159-
filePush(result);
160-
}
161-
catch (error) {
162-
return errorM(error);
163-
}
164-
}
165-
});
166-
};
142+
}
143+
});
167144

168145
//////////////////////////////
169146
// Sync Sass render
170147
//////////////////////////////
171-
gulpSass.sync = function sync(options) {
172-
return gulpSass(options, true);
173-
};
148+
gulpSass.sync = options => gulpSass(options, true);
174149

175150
//////////////////////////////
176151
// Log errors nicely
177152
//////////////////////////////
178-
gulpSass.logError = function logError(error) {
179-
var message = new gutil.PluginError('sass', error.messageFormatted).toString();
180-
process.stderr.write(message + '\n');
153+
gulpSass.logError = (error) => {
154+
const message = new PluginError('sass', error.messageFormatted).toString();
155+
process.stderr.write(`${message}\n`);
181156
this.emit('end');
182157
};
183158

‎package.json

+16-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "3.2.1",
44
"description": "Gulp plugin for sass",
55
"main": "index.js",
6+
"engines": {
7+
"node": ">=6"
8+
},
69
"scripts": {
710
"test": "./node_modules/.bin/mocha test"
811
},
@@ -21,22 +24,28 @@
2124
"url": "https://github.com/dlmanning/gulp-sass/issues"
2225
},
2326
"dependencies": {
24-
"gulp-util": "^3.0",
27+
"chalk": "^2.3.0",
2528
"lodash.clonedeep": "^4.3.2",
2629
"node-sass": "^4.8.3",
30+
"plugin-error": "^1.0.1",
31+
"replace-ext": "^1.0.0",
32+
"strip-ansi": "^4.0.0",
2733
"through2": "^2.0.0",
2834
"vinyl-sourcemaps-apply": "^0.2.0"
2935
},
3036
"devDependencies": {
31-
"autoprefixer-core": "^5.2.1",
32-
"eslint": "^2.9.0",
37+
"autoprefixer": "^8.1.0",
38+
"eslint": "^4.18.2",
39+
"eslint-config-airbnb-base": "^12.1.0",
40+
"eslint-plugin-import": "^2.9.0",
3341
"globule": "^1.0.0",
3442
"gulp": "^3.8.11",
35-
"gulp-postcss": "^5.1.10",
36-
"gulp-sourcemaps": "^1.5.2",
43+
"gulp-postcss": "^7.0.1",
44+
"gulp-sourcemaps": "^2.6.4",
3745
"gulp-tap": "^0.1.3",
38-
"mocha": "^2.2.1",
46+
"mocha": "^5.0.4",
3947
"rimraf": "^2.4.3",
40-
"should": "^8.3.1"
48+
"should": "^13.2.1",
49+
"vinyl": "^2.1.0"
4150
}
4251
}

‎test/lint.js

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
'use strict';
1+
const eslint = require('eslint');
2+
const should = require('should');
23

3-
var eslint = require('eslint');
4-
var should = require('should');
4+
describe('code style guide', () => {
5+
it('index.js should follow our lint style guide', (done) => {
6+
const cli = new eslint.CLIEngine({ rules: { 'spaced-comment': 0 } });
7+
const formatter = cli.getFormatter();
8+
const report = cli.executeOnFiles(['index.js']);
59

6-
var cli = new eslint.CLIEngine();
7-
var formatter = cli.getFormatter();
8-
9-
var report;
10-
11-
describe('code style guide', function() {
12-
it('index.js should follow our lint style guide', function(done) {
13-
report = cli.executeOnFiles(['index.js']);
1410
if (report.errorCount > 0 || report.warningCount > 0) {
1511
console.log(formatter(report.results));
1612
}
@@ -20,8 +16,11 @@ describe('code style guide', function() {
2016
done();
2117
});
2218

23-
it('test/main.js should follow our lint style guide', function(done) {
24-
report = cli.executeOnFiles(['test/main.js']);
19+
it('test/main.js should follow our lint style guide', (done) => {
20+
const cli = new eslint.CLIEngine();
21+
const formatter = cli.getFormatter();
22+
const report = cli.executeOnFiles(['test/main.js']);
23+
2524
if (report.errorCount > 0 || report.warningCount > 0) {
2625
console.log(formatter(report.results));
2726
}
@@ -31,13 +30,11 @@ describe('code style guide', function() {
3130
done();
3231
});
3332

34-
it('test/lint.js should follow our lint style guide', function(done) {
35-
cli = new eslint.CLIEngine({
36-
'rules': {
37-
'no-console': 0
38-
}
39-
});
40-
report = cli.executeOnFiles(['test/lint.js']);
33+
it('test/lint.js should follow our lint style guide', (done) => {
34+
const cli = new eslint.CLIEngine({ rules: { 'no-console': 0 } });
35+
const formatter = cli.getFormatter();
36+
const report = cli.executeOnFiles(['test/lint.js']);
37+
4138
if (report.errorCount > 0 || report.warningCount > 0) {
4239
console.log(formatter(report.results));
4340
}

‎test/main.js

+203-227
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.