Skip to content

Commit 5dc705c

Browse files
committedMay 22, 2017
#43 ; dep updated (clean-css 4.1.3)
1 parent eeee392 commit 5dc705c

File tree

3 files changed

+157
-159
lines changed

3 files changed

+157
-159
lines changed
 

‎index.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ module.exports = function gulpCleanCSS(options, callback) {
2727
options.sourceMap = JSON.parse(JSON.stringify(file.sourceMap));
2828

2929
let contents = file.contents ? file.contents.toString() : '';
30-
let style = {
31-
[file.path]: {
32-
styles: contents
33-
}
34-
};
30+
let pass = options.rebaseTo ? {[file.path]: {styles: contents}} : contents;
3531

36-
new CleanCSS(options).minify(style, function (errors, css) {
32+
new CleanCSS(options).minify(pass, function (errors, css) {
3733

3834
if (errors)
3935
return cb(errors.join(' '));

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gulp-clean-css",
33
"description": "Minify css with clean-css.",
44
"homepage": "https://github.com/scniro/gulp-clean-css#readme",
5-
"version": "3.3.1",
5+
"version": "3.4.0",
66
"author": "scniro",
77
"license": "MIT",
88
"bugs": {
@@ -29,7 +29,7 @@
2929
"gulpfriendly"
3030
],
3131
"dependencies": {
32-
"clean-css": "4.1.2",
32+
"clean-css": "4.1.3",
3333
"gulp-util": "3.0.8",
3434
"through2": "2.0.3",
3535
"vinyl-sourcemaps-apply": "0.2.1"
@@ -39,7 +39,7 @@
3939
"chai-string": "1.3.0",
4040
"coveralls": "2.13.1",
4141
"del": "2.2.2",
42-
"express": "4.15.2",
42+
"express": "4.15.3",
4343
"gulp": "3.9.1",
4444
"gulp-concat": "2.6.1",
4545
"gulp-istanbul": "1.1.1",

‎test/test.js

+152-150
Original file line numberDiff line numberDiff line change
@@ -27,54 +27,54 @@ describe('gulp-clean-css: base functionality', function () {
2727
var i = 0;
2828

2929
gulp.src(['test/fixtures/**/*.scss', '!test/fixtures/empty/**', '!test/fixtures/sourcemaps-load/**'])
30-
.pipe(gulpSass())
31-
.pipe(cleanCSS())
32-
.pipe(rename({
33-
suffix: '.generated',
34-
}))
35-
.pipe(gulp.dest('test/fixtures/'))
36-
.on('data', function (file) {
37-
i += 1;
38-
})
39-
.once('end', function () {
40-
i.should.equal(3);
41-
done();
42-
});
30+
.pipe(gulpSass())
31+
.pipe(cleanCSS())
32+
.pipe(rename({
33+
suffix: '.generated',
34+
}))
35+
.pipe(gulp.dest('test/fixtures/'))
36+
.on('data', function (file) {
37+
i += 1;
38+
})
39+
.once('end', function () {
40+
i.should.equal(3);
41+
done();
42+
});
4343
});
4444

4545
it('should allow the file through', function (done) {
4646
var i = 0;
4747

4848
gulp.src('test/fixtures/test.css')
49-
.pipe(cleanCSS())
50-
.on('data', function (file) {
51-
i += 1;
52-
})
53-
.once('end', function () {
54-
i.should.equal(1);
55-
done();
56-
});
49+
.pipe(cleanCSS())
50+
.on('data', function (file) {
51+
i += 1;
52+
})
53+
.once('end', function () {
54+
i.should.equal(1);
55+
done();
56+
});
5757
});
5858

5959
it('should allow the file through:empty file, pipe dest', function (done) {
6060
var i = 0;
6161

6262
gulp.src('test/fixtures/empty/**/*.scss')
63-
.pipe(gulpSass())
64-
.pipe(cleanCSS())
65-
.pipe(rename({
66-
suffix: '.generated',
67-
}))
68-
.pipe(gulp.dest(function (file) {
69-
return file.base + '/empty-parsed';
70-
}))
71-
.on('data', function (file) {
72-
i += 1;
73-
})
74-
.once('end', function () {
75-
i.should.equal(3);
76-
done();
77-
});
63+
.pipe(gulpSass())
64+
.pipe(cleanCSS())
65+
.pipe(rename({
66+
suffix: '.generated',
67+
}))
68+
.pipe(gulp.dest(function (file) {
69+
return file.base + '/empty-parsed';
70+
}))
71+
.on('data', function (file) {
72+
i += 1;
73+
})
74+
.once('end', function () {
75+
i.should.equal(3);
76+
done();
77+
});
7878
});
7979

8080
it('should produce the expected file', function (done) {
@@ -87,11 +87,11 @@ describe('gulp-clean-css: base functionality', function () {
8787
});
8888

8989
gulp.src('test/fixtures/test.css')
90-
.pipe(cleanCSS())
91-
.on('data', function (file) {
92-
file.contents.should.exist && expect(file.contents.toString()).to.equal(mockFile.contents.toString());
93-
done();
94-
});
90+
.pipe(cleanCSS())
91+
.on('data', function (file) {
92+
file.contents.should.exist && expect(file.contents.toString()).to.equal(mockFile.contents.toString());
93+
done();
94+
});
9595
});
9696

9797
it('should minify the css: empty file, no `file.contents`', function (done) {
@@ -106,111 +106,111 @@ describe('gulp-clean-css: base functionality', function () {
106106
});
107107

108108
vfsFake.src(mockFile)
109-
.pipe(cleanCSS())
110-
.on('data', function (file) {
111-
i += 1;
112-
})
113-
.once('end', function () {
114-
i.should.equal(1);
115-
done();
116-
});
109+
.pipe(cleanCSS())
110+
.on('data', function (file) {
111+
i += 1;
112+
})
113+
.once('end', function () {
114+
i.should.equal(1);
115+
done();
116+
});
117117
});
118118

119119
it('should invoke optional callback with details specified in options: debug', function (done) {
120120
gulp.src('test/fixtures/test.css')
121-
.pipe(cleanCSS({debug: true}, function (details) {
122-
details.stats.should.exist &&
123-
details.stats.originalSize.should.exist &&
124-
details.stats.minifiedSize.should.exist;
125-
}))
126-
.on('data', function (file) {
127-
done();
128-
});
121+
.pipe(cleanCSS({debug: true}, function (details) {
122+
details.stats.should.exist &&
123+
details.stats.originalSize.should.exist &&
124+
details.stats.minifiedSize.should.exist;
125+
}))
126+
.on('data', function (file) {
127+
done();
128+
});
129129
});
130130

131131
it('should invoke optional callback with out options object supplied: return object hash', function (done) {
132132
gulp.src('test/fixtures/test.css')
133-
.pipe(cleanCSS(function (details) {
134-
details.stats.should.exist &&
135-
expect(details).to.have.ownProperty('stats') &&
136-
expect(details).to.have.ownProperty('errors') &&
137-
expect(details).to.have.ownProperty('warnings') &&
138-
expect(details).to.not.have.ownProperty('sourceMap');
139-
}))
140-
.on('data', function (file) {
141-
done();
142-
});
133+
.pipe(cleanCSS(function (details) {
134+
details.stats.should.exist &&
135+
expect(details).to.have.ownProperty('stats') &&
136+
expect(details).to.have.ownProperty('errors') &&
137+
expect(details).to.have.ownProperty('warnings') &&
138+
expect(details).to.not.have.ownProperty('sourceMap');
139+
}))
140+
.on('data', function (file) {
141+
done();
142+
});
143143
});
144144

145145
it('should invoke optional callback without options object supplied: return object hash with sourceMap: true; return correct hash', function (done) {
146146
gulp.src('test/fixtures/test.css')
147-
.pipe(cleanCSS({sourceMap: true}, function (details) {
148-
details.stats.should.exist &&
149-
expect(details).have.ownProperty('sourceMap');
150-
}))
151-
.on('data', function (file) {
152-
done();
153-
});
147+
.pipe(cleanCSS({sourceMap: true}, function (details) {
148+
details.stats.should.exist &&
149+
expect(details).have.ownProperty('sourceMap');
150+
}))
151+
.on('data', function (file) {
152+
done();
153+
});
154154
});
155155

156156
it('should invoke optional callback with file details returned', function (done) {
157157

158158
var expected = 'test.css'
159159

160160
gulp.src('test/fixtures/test.css')
161-
.pipe(cleanCSS(function (details) {
162-
details.name.should.equal(expected)
163-
}))
164-
.on('data', function (file) {
165-
done();
166-
});
161+
.pipe(cleanCSS(function (details) {
162+
details.name.should.equal(expected)
163+
}))
164+
.on('data', function (file) {
165+
done();
166+
});
167167
});
168168

169169
it('should write sourcemaps', function (done) {
170170

171171
var i = 0;
172172

173173
gulp.src(['test/fixtures/sourcemaps/**/*.css', '!test/fixtures/sourcemaps/**/*.generated.css'])
174-
.pipe(sourcemaps.init())
175-
.pipe(concat('sourcemapped.css'))
176-
.pipe(cleanCSS())
177-
.pipe(rename({
178-
suffix: '.generated',
179-
}))
180-
.on('data', function (file) {
181-
i += 1;
182-
})
183-
.pipe(sourcemaps.write())
184-
.pipe(gulp.dest(function (file) {
185-
return file.base;
186-
}))
187-
.once('end', function () {
188-
i.should.equal(1);
189-
done();
190-
});
174+
.pipe(sourcemaps.init())
175+
.pipe(concat('sourcemapped.css'))
176+
.pipe(cleanCSS())
177+
.pipe(rename({
178+
suffix: '.generated',
179+
}))
180+
.on('data', function (file) {
181+
i += 1;
182+
})
183+
.pipe(sourcemaps.write())
184+
.pipe(gulp.dest(function (file) {
185+
return file.base;
186+
}))
187+
.once('end', function () {
188+
i.should.equal(1);
189+
done();
190+
});
191191
});
192192

193193
it('should write sourcemaps, worrectly map output', function (done) {
194194

195195
var i = 0;
196196

197197
gulp.src('test/fixtures/sourcemaps-load/scss/test-sass.scss')
198-
.pipe(sourcemaps.init())
199-
.pipe(gulpSass())
200-
.pipe(sourcemaps.init({loadMaps: true}))
201-
.pipe(cleanCSS({sourceMapInlineSources: true}))
202-
.on('data', function (file) {
203-
i += 1;
204-
})
205-
.pipe(rename({
206-
suffix: '.min'
207-
}))
208-
.pipe(sourcemaps.write())
209-
.pipe(gulp.dest('test/fixtures/sourcemaps-load/min'))
210-
.once('end', function () {
211-
i.should.equal(1); // todo inspect mapping here
212-
done();
213-
});
198+
.pipe(sourcemaps.init())
199+
.pipe(gulpSass())
200+
.pipe(sourcemaps.init({loadMaps: true}))
201+
.pipe(cleanCSS({sourceMapInlineSources: true}))
202+
.on('data', function (file) {
203+
i += 1;
204+
})
205+
.pipe(rename({
206+
suffix: '.min'
207+
}))
208+
.pipe(sourcemaps.write())
209+
.pipe(gulp.dest('test/fixtures/sourcemaps-load/min'))
210+
.once('end', function () {
211+
i.should.equal(1); // todo inspect mapping here
212+
done();
213+
});
214214
});
215215

216216
it('should return a warning for improper syntax', function (done) {
@@ -223,28 +223,28 @@ describe('gulp-clean-css: base functionality', function () {
223223
});
224224

225225
vfsFake.src(css)
226-
.pipe(cleanCSS({debug: true}, function (details) {
227-
expect(details.warnings).to.exist &&
228-
expect(details.warnings.length).to.equal(1) &&
229-
expect(details.warnings[0]).to.equal('Missing \'}\' at fixtures/test.css:1:14.');
230-
}))
231-
.on('data', function (file) {
232-
i += 1;
233-
})
234-
.once('end', function () {
235-
i.should.equal(1);
236-
done();
237-
});
226+
.pipe(cleanCSS({debug: true}, function (details) {
227+
expect(details.warnings).to.exist &&
228+
expect(details.warnings.length).to.equal(1) &&
229+
expect(details.warnings[0]).to.equal('Missing \'}\' at 1:14.');
230+
}))
231+
.on('data', function (file) {
232+
i += 1;
233+
})
234+
.once('end', function () {
235+
i.should.equal(1);
236+
done();
237+
});
238238
});
239239

240240
it('should invoke a plugin error: streaming not supported', function (done) {
241241

242242
gulp.src('test/fixtures/test.css', {buffer: false})
243-
.pipe(cleanCSS()
244-
.on('error', function (err) {
245-
expect(err.message).to.equal('Streaming not supported!')
246-
done();
247-
}));
243+
.pipe(cleanCSS()
244+
.on('error', function (err) {
245+
expect(err.message).to.equal('Streaming not supported!')
246+
done();
247+
}));
248248
});
249249

250250
it('should return a clean-css error', function (done) {
@@ -255,52 +255,54 @@ describe('gulp-clean-css: base functionality', function () {
255255
});
256256

257257
vfsFake.src(css)
258-
.pipe(cleanCSS())
259-
.on('error', function (err) {
260-
expect(err).to.exist;
261-
expect(err).to.equal('Ignoring local @import of "/some/fake/file" as resource is missing.');
262-
done();
263-
});
258+
.pipe(cleanCSS())
259+
.on('error', function (err) {
260+
expect(err).to.exist;
261+
expect(err).to.equal('Ignoring local @import of "/some/fake/file" as resource is missing.');
262+
done();
263+
});
264264
});
265265
});
266266

267267
describe('gulp-clean-css: rebase', function () {
268+
268269
it('should not rebase files by default - do not resolve relative files', function (done) {
269270

270271
gulp.src(['test/fixtures/rebasing/subdir/insub.css'])
271-
.pipe(cleanCSS({rebase: false}))
272-
.on('data', function (file) {
272+
.pipe(cleanCSS({rebase: false}))
273+
.on('data', function (file) {
273274

274-
let expected = `
275+
let expected = `
275276
p.insub_same{background:url(insub.png)}
276277
p.insub_child{background:url(child/child.png)}
277278
p.insub_parent{background:url(../parent.png)}
278279
p.insub_other{background:url(../othersub/inother.png)}
279280
p.insub_absolute{background:url(/inroot.png)}`;
280281

281-
let actual = file.contents.toString();
282+
let actual = file.contents.toString();
282283

283-
expect(actual).to.equalIgnoreSpaces(expected)
284-
})
285-
.once('end', done);
284+
expect(actual).to.equalIgnoreSpaces(expected)
285+
})
286+
.once('end', done);
286287
});
287288

288289
it('should by rebase files with target specified', function (done) {
290+
289291
gulp.src(['test/fixtures/rebasing/subdir/insub.css'])
290-
.pipe(cleanCSS({rebaseTo: 'test'}))
291-
.on('data', function (file) {
292+
.pipe(cleanCSS({rebaseTo: 'test'}))
293+
.on('data', function (file) {
292294

293-
let expected = `
295+
let expected = `
294296
p.insub_same{background:url(fixtures/rebasing/subdir/insub.png)}
295297
p.insub_child{background:url(fixtures/rebasing/subdir/child/child.png)}
296298
p.insub_parent{background:url(fixtures/rebasing/parent.png)}
297299
p.insub_other{background:url(fixtures/rebasing/othersub/inother.png)}
298300
p.insub_absolute{background:url(/inroot.png)}`;
299301

300-
let actual = file.contents.toString();
302+
let actual = file.contents.toString();
301303

302-
expect(actual).to.equalIgnoreSpaces(expected);
303-
})
304-
.once('end', done);
304+
expect(actual).to.equalIgnoreSpaces(expected);
305+
})
306+
.once('end', done);
305307
});
306308
});

0 commit comments

Comments
 (0)
Please sign in to comment.