Skip to content

Commit fd5d3bf

Browse files
committed
fix(gulp-purgecss): fix support for stream input
1 parent 365fb60 commit fd5d3bf

File tree

11 files changed

+1934
-1422
lines changed

11 files changed

+1934
-1422
lines changed

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
preset: "ts-jest",
33
coverageDirectory: "coverage",
44
coverageReporters: ["html", "lcov", "text"],
5-
collectCoverageFrom: ["packages/*/src/**/*.ts"],
5+
collectCoverageFrom: ["packages/*/src/**/*.ts", "!packages/grunt-purgecss/**/*.ts"],
66
moduleFileExtensions: ["ts", "tsx", "js", "json"],
77
moduleNameMapper: {
88
"^purgecss$": "<rootDir>/packages/purgecss/src",

package-lock.json

+833-678
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@
1818
"@rollup/plugin-json": "^4.1.0",
1919
"@types/jest": "^27.0.2",
2020
"@types/node": "^16.0.0",
21-
"@typescript-eslint/eslint-plugin": "^5.3.0",
22-
"@typescript-eslint/parser": "^5.3.0",
21+
"@typescript-eslint/eslint-plugin": "^5.4.0",
22+
"@typescript-eslint/parser": "^5.4.0",
2323
"@vuepress/plugin-google-analytics": "^1.8.2",
2424
"@vuepress/theme-default": "^1.8.2",
2525
"conventional-changelog-cli": "^2.1.1",
26-
"eslint": "^8.2.0",
26+
"eslint": "^8.3.0",
2727
"husky": "^7.0.1",
2828
"jest": "^27.3.1",
2929
"lerna": "^4.0.0",
30-
"lint-staged": "^11.0.0",
31-
"prettier": "^2.4.1",
32-
"rollup": "^2.59.0",
30+
"lint-staged": "^12.0.0",
31+
"prettier": "^2.5.0",
32+
"rollup": "^2.60.0",
3333
"rollup-plugin-node-resolve": "^5.2.0",
3434
"rollup-plugin-terser": "^7.0.2",
35-
"rollup-plugin-ts": "^1.4.0",
35+
"rollup-plugin-ts": "^2.0.0",
3636
"ts-jest": "^27.0.7",
3737
"ts-node": "^10.4.0",
38-
"typescript": "^4.4.4",
38+
"typescript": "^4.5.2",
3939
"vuepress": "^1.8.2"
4040
},
4141
"scripts": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import es from 'event-stream';
2+
import internal, { PassThrough } from "stream";
3+
import File from "vinyl";
4+
import gulpPurgecss from "../src/";
5+
6+
describe("gulp-purgecss with stream", () => {
7+
let myGulpPurgecss: internal.Transform;
8+
let fileTest: File.StreamFile;
9+
let fakeStream: internal.PassThrough;
10+
11+
beforeEach(() => {
12+
fakeStream = new PassThrough();
13+
fakeStream.write(Buffer.from(".unused, .used,"));
14+
fakeStream.write(Buffer.from(" a { color:"));
15+
fakeStream.write(Buffer.from(" blue; }"));
16+
fakeStream.end();
17+
fileTest = new File({
18+
contents: fakeStream,
19+
});
20+
myGulpPurgecss = gulpPurgecss({
21+
content: ["./packages/gulp-purgecss/__tests__/test.html"],
22+
});
23+
});
24+
25+
// it("returns a stream", (done) => {
26+
// expect.assertions(1);
27+
// myGulpPurgecss.write(fileTest);
28+
// myGulpPurgecss.once("data", (file) => {
29+
// expect(file.isStream()).toBe(true);
30+
// done();
31+
// });
32+
// });
33+
34+
it("returns a purged css stream", (done) => {
35+
expect.assertions(3);
36+
myGulpPurgecss.write(fileTest);
37+
myGulpPurgecss.on("data", (file: File.StreamFile) => {
38+
file.contents.pipe(
39+
es.wait((_err: any, data: string) => {
40+
expect(data.includes("used")).toBe(true);
41+
expect(data.includes("unused")).toBe(false);
42+
expect(data.includes("a")).toBe(true);
43+
done();
44+
})
45+
);
46+
});
47+
// myGulpPurgecss.on("end", done);
48+
});
49+
50+
});

0 commit comments

Comments
 (0)