Skip to content

Commit 26c31c0

Browse files
committedFeb 3, 2018
Require Node.js 8
1 parent 276257e commit 26c31c0

9 files changed

+94
-119
lines changed
 

‎.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[{package.json,*.yml}]
10+
[*.yml]
1111
indent_style = space
1212
indent_size = 2

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
yarn.lock

‎.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

‎.travis.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
sudo: false
21
language: node_js
32
node_js:
4-
- '7'
5-
- '6'
6-
- '5'
7-
- '4'
8-
- '0.12'
9-
- '0.10'
3+
- '8'

‎gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
module.exports = function (grunt) {
2+
module.exports = grunt => {
33
grunt.initConfig({
44
sass: {
55
compile: {

‎license

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
The MIT License (MIT)
1+
MIT License
22

33
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎package.json

+42-45
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
11
{
2-
"name": "grunt-sass",
3-
"version": "2.1.0",
4-
"description": "Compile Sass to CSS using node-sass",
5-
"license": "MIT",
6-
"repository": "sindresorhus/grunt-sass",
7-
"author": {
8-
"name": "Sindre Sorhus",
9-
"email": "sindresorhus@gmail.com",
10-
"url": "sindresorhus.com"
11-
},
12-
"engines": {
13-
"node": ">=0.10.0"
14-
},
15-
"scripts": {
16-
"test": "xo && grunt"
17-
},
18-
"files": [
19-
"tasks"
20-
],
21-
"keywords": [
22-
"gruntplugin",
23-
"css",
24-
"sass",
25-
"scss",
26-
"style",
27-
"compile",
28-
"preprocess",
29-
"compile",
30-
"libsass"
31-
],
32-
"dependencies": {
33-
"each-async": "^1.0.0",
34-
"node-sass": "^4.7.2",
35-
"object-assign": "^4.0.1"
36-
},
37-
"devDependencies": {
38-
"grunt": "^1.0.1",
39-
"grunt-cli": "^1.2.0",
40-
"grunt-contrib-clean": "^1.0.0",
41-
"grunt-contrib-nodeunit": "^1.0.0",
42-
"xo": "^0.16.0"
43-
},
44-
"peerDependencies": {
45-
"grunt": ">=0.4.0"
46-
}
2+
"name": "grunt-sass",
3+
"version": "2.1.0",
4+
"description": "Compile Sass to CSS using node-sass",
5+
"license": "MIT",
6+
"repository": "sindresorhus/grunt-sass",
7+
"author": {
8+
"name": "Sindre Sorhus",
9+
"email": "sindresorhus@gmail.com",
10+
"url": "sindresorhus.com"
11+
},
12+
"engines": {
13+
"node": ">=8"
14+
},
15+
"scripts": {
16+
"test": "xo && grunt"
17+
},
18+
"files": [
19+
"tasks"
20+
],
21+
"keywords": [
22+
"gruntplugin",
23+
"css",
24+
"sass",
25+
"scss",
26+
"style",
27+
"compile",
28+
"preprocess",
29+
"libsass"
30+
],
31+
"dependencies": {
32+
"node-sass": "^4.7.2"
33+
},
34+
"devDependencies": {
35+
"grunt": "^1.0.1",
36+
"grunt-cli": "^1.2.0",
37+
"grunt-contrib-clean": "^1.0.0",
38+
"grunt-contrib-nodeunit": "^1.0.0",
39+
"xo": "*"
40+
},
41+
"peerDependencies": {
42+
"grunt": ">=1"
43+
}
4744
}

‎tasks/sass.js

+26-32
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
11
'use strict';
2-
var path = require('path');
3-
var eachAsync = require('each-async');
4-
var assign = require('object-assign');
5-
var sass = require('node-sass');
2+
const util = require('util');
3+
const path = require('path');
4+
const sass = require('node-sass');
65

7-
module.exports = function (grunt) {
8-
grunt.verbose.writeln('\n' + sass.info + '\n');
6+
module.exports = grunt => {
7+
grunt.verbose.writeln(`\n${sass.info}\n`);
98

10-
grunt.registerMultiTask('sass', 'Compile Sass to CSS', function () {
11-
eachAsync(this.files, function (el, i, next) {
12-
var opts = this.options({
13-
precision: 10
14-
});
9+
grunt.registerMultiTask('sass', 'Compile Sass to CSS', async function () {
10+
const done = this.async();
1511

16-
var src = el.src[0];
12+
const options = this.options({
13+
precision: 10
14+
});
15+
16+
await Promise.all(this.files.map(async item => {
17+
const src = item.src[0];
1718

1819
if (!src || path.basename(src)[0] === '_') {
19-
next();
2020
return;
2121
}
2222

23-
sass.render(assign({}, opts, {
23+
const result = await util.promisify(sass.render)(Object.assign({}, options, {
2424
file: src,
25-
outFile: el.dest
26-
}), function (err, res) {
27-
if (err) {
28-
grunt.log.error(err.formatted + '\n');
29-
grunt.warn('');
30-
next(err);
31-
return;
32-
}
33-
34-
grunt.file.write(el.dest, res.css);
35-
36-
if (opts.sourceMap) {
37-
grunt.file.write(this.options.sourceMap, res.map);
38-
}
39-
40-
next();
41-
});
42-
}.bind(this), this.async());
25+
outFile: item.dest
26+
}));
27+
28+
grunt.file.write(item.dest, result.css);
29+
30+
if (options.sourceMap) {
31+
const filePath = options.sourceMap === true ? `${item.dest}.map` : options.sourceMap;
32+
grunt.file.write(filePath, result.map);
33+
}
34+
}));
35+
36+
done();
4337
});
4438
};

‎test/test.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
'use strict';
2-
var grunt = require('grunt');
2+
const grunt = require('grunt');
33

44
exports.sass = {
5-
compile: function (test) {
5+
compile(test) {
66
test.expect(2);
77

8-
var actual = grunt.file.read('test/tmp/compile.css');
9-
var actual2 = grunt.file.read('test/tmp/compile2.css');
10-
var expected = grunt.file.read('test/expected/compile.css');
8+
const actual = grunt.file.read('test/tmp/compile.css');
9+
const actual2 = grunt.file.read('test/tmp/compile2.css');
10+
const expected = grunt.file.read('test/expected/compile.css');
1111
test.equal(actual, expected, 'should compile SCSS to CSS');
1212
test.equal(actual2, expected, 'should compile SCSS to CSS');
1313

1414
test.done();
1515
},
16-
includePaths: function (test) {
16+
includePaths(test) {
1717
test.expect(1);
1818

19-
var actual = grunt.file.read('test/tmp/include-paths.css');
20-
var expected = grunt.file.read('test/expected/include-paths.css');
19+
const actual = grunt.file.read('test/tmp/include-paths.css');
20+
const expected = grunt.file.read('test/expected/include-paths.css');
2121
test.equal(actual, expected, 'should compile SCSS to CSS with options');
2222

2323
test.done();
2424
},
25-
ignorePartials: function (test) {
25+
ignorePartials(test) {
2626
test.expect(1);
2727

2828
test.ok(!grunt.file.exists('test/tmp/_partial.css'), 'underscore partial files should be ignored');
2929

3030
test.done();
3131
},
32-
sourceMap: function (test) {
32+
sourceMap(test) {
3333
test.expect(2);
3434

35-
var css = grunt.file.read('test/tmp/source-map.css');
35+
const css = grunt.file.read('test/tmp/source-map.css');
3636
test.ok(/\/\*# sourceMappingURL=source-map\.css\.map/.test(css), 'should include sourceMapppingUrl');
3737

38-
var map = grunt.file.read('test/tmp/source-map.css.map');
38+
const map = grunt.file.read('test/tmp/source-map.css.map');
3939
test.ok(/test\.scss/.test(map), 'should include the main file in sourceMap at least');
4040
test.done();
4141
},
42-
sourceMapSimple: function (test) {
42+
sourceMapSimple(test) {
4343
test.expect(2);
4444

45-
var css = grunt.file.read('test/tmp/source-map-simple.css');
45+
const css = grunt.file.read('test/tmp/source-map-simple.css');
4646
test.ok(/\/\*# sourceMappingURL=source-map-simple\.css\.map/.test(css), 'should include sourceMappingUrl');
4747

48-
var map = grunt.file.read('test/tmp/source-map-simple.css.map');
48+
const map = grunt.file.read('test/tmp/source-map-simple.css.map');
4949
test.ok(/test\.scss"/.test(map), 'should include the main file in sourceMap at least');
5050
test.done();
5151
},
52-
precision: function (test) {
52+
precision(test) {
5353
test.expect(1);
5454

55-
var actual = grunt.file.read('test/tmp/precision.css');
55+
const actual = grunt.file.read('test/tmp/precision.css');
5656
test.ok(/1\.343/.test(actual), 'should support precision option');
5757

5858
test.done();

0 commit comments

Comments
 (0)
Please sign in to comment.