gulp-expect-file 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -12
- package/index.js +12 -21
- package/lib/file-tester.js +3 -7
- package/lib/stream-tester.js +7 -3
- package/lib/string-tester.js +6 -3
- package/package.json +24 -18
- package/.eslintrc +0 -7
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# gulp-expect-file [![NPM version][npm-image]][npm-url] [![Build Status][gh-image]][gh-url]
|
|
1
|
+
# gulp-expect-file [![NPM version][npm-image]][npm-url] [![Build Status][gh-image]][gh-url]
|
|
2
2
|
|
|
3
|
-
> Expectation on generated files for
|
|
3
|
+
> Expectation on generated files for Gulp 4
|
|
4
4
|
|
|
5
|
-
This plugin is intended for testing other
|
|
5
|
+
This plugin is intended for testing other Gulp plugin.
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
@@ -20,10 +20,7 @@ Then, add it to your `gulpfile.js`:
|
|
|
20
20
|
var expect = require("gulp-expect-file");
|
|
21
21
|
|
|
22
22
|
gulp.task("copy", function () {
|
|
23
|
-
gulp
|
|
24
|
-
.src(["src/foo.txt"])
|
|
25
|
-
.pipe(gulp.dest("dest/"))
|
|
26
|
-
.pipe(expect("dest/foo.txt"));
|
|
23
|
+
gulp.src(["src/foo.txt"]).pipe(gulp.dest("dest/")).pipe(expect("dest/foo.txt"));
|
|
27
24
|
});
|
|
28
25
|
```
|
|
29
26
|
|
|
@@ -114,9 +111,7 @@ Default: `false`
|
|
|
114
111
|
If true, it also checks if the real file exists on the file system by `fs.exists()`.
|
|
115
112
|
|
|
116
113
|
```js
|
|
117
|
-
gulp
|
|
118
|
-
.src(["exist.txt", "nonexist.txt"])
|
|
119
|
-
.pipe(expect({ checkRealFile: true }, "*.txt"));
|
|
114
|
+
gulp.src(["exist.txt", "nonexist.txt"]).pipe(expect({ checkRealFile: true }, "*.txt"));
|
|
120
115
|
|
|
121
116
|
// => FAIL: nonexist.txt not exists on filesystem
|
|
122
117
|
```
|
|
@@ -159,5 +154,3 @@ This is just a shortcut for `expect({ checkRealFile: true }, expectation)`.
|
|
|
159
154
|
[npm-image]: https://img.shields.io/npm/v/gulp-expect-file.svg
|
|
160
155
|
[gh-url]: https://github.com/pioug/gulp-expect-file/actions/workflows/test.yml
|
|
161
156
|
[gh-image]: https://github.com/pioug/gulp-expect-file/actions/workflows/test.yml/badge.svg
|
|
162
|
-
[daviddm-url]: https://david-dm.org/pioug/gulp-expect-file
|
|
163
|
-
[daviddm-image]: https://img.shields.io/david/pioug/gulp-expect-file.svg
|
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ function expect(options, expectation) {
|
|
|
36
36
|
silent: false,
|
|
37
37
|
verbose: false,
|
|
38
38
|
},
|
|
39
|
-
options
|
|
39
|
+
options,
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
try {
|
|
@@ -94,10 +94,7 @@ function expect(options, expectation) {
|
|
|
94
94
|
if (numFailures > 0 && options.errorOnFailure) {
|
|
95
95
|
this.emit(
|
|
96
96
|
"error",
|
|
97
|
-
new PluginError(
|
|
98
|
-
"gulp-expect-file",
|
|
99
|
-
"Failed " + numFailures + " expectations"
|
|
100
|
-
)
|
|
97
|
+
new PluginError("gulp-expect-file", "Failed " + numFailures + " expectations"),
|
|
101
98
|
);
|
|
102
99
|
}
|
|
103
100
|
|
|
@@ -107,20 +104,13 @@ function expect(options, expectation) {
|
|
|
107
104
|
|
|
108
105
|
function reportFailure(file, err) {
|
|
109
106
|
if (err instanceof ExpectationError) {
|
|
110
|
-
options.silent
|
|
111
|
-
log(
|
|
112
|
-
|
|
113
|
-
colors.magenta(file.relative),
|
|
114
|
-
"is",
|
|
115
|
-
err.message
|
|
116
|
-
);
|
|
107
|
+
if (!options.silent) {
|
|
108
|
+
log(colors.red("\u2717 FAIL:"), colors.magenta(file.relative), "is", err.message);
|
|
109
|
+
}
|
|
117
110
|
} else {
|
|
118
|
-
options.silent
|
|
119
|
-
log(
|
|
120
|
-
|
|
121
|
-
colors.magenta(file.relative) + ":",
|
|
122
|
-
err.message || err
|
|
123
|
-
);
|
|
111
|
+
if (!options.silent) {
|
|
112
|
+
log(colors.red("\u2717 ERROR:"), colors.magenta(file.relative) + ":", err.message || err);
|
|
113
|
+
}
|
|
124
114
|
}
|
|
125
115
|
}
|
|
126
116
|
|
|
@@ -142,13 +132,13 @@ function expect(options, expectation) {
|
|
|
142
132
|
"Missing",
|
|
143
133
|
colors.cyan(rules.length),
|
|
144
134
|
"expected files:",
|
|
145
|
-
colors.magenta(missings)
|
|
135
|
+
colors.magenta(missings),
|
|
146
136
|
);
|
|
147
137
|
}
|
|
148
138
|
}
|
|
149
139
|
|
|
150
140
|
function reportSummary() {
|
|
151
|
-
options.silent
|
|
141
|
+
if (!options.silent) {
|
|
152
142
|
log(
|
|
153
143
|
"Tested",
|
|
154
144
|
colors.cyan(numTests),
|
|
@@ -157,8 +147,9 @@ function expect(options, expectation) {
|
|
|
157
147
|
"passes,",
|
|
158
148
|
colors.cyan(numFailures),
|
|
159
149
|
"failures:",
|
|
160
|
-
numFailures > 0 ? colors.bgRed.white("FAIL") : colors.green("PASS")
|
|
150
|
+
numFailures > 0 ? colors.bgRed.white("FAIL") : colors.green("PASS"),
|
|
161
151
|
);
|
|
152
|
+
}
|
|
162
153
|
}
|
|
163
154
|
|
|
164
155
|
return through.obj(eachFile, endStream);
|
package/lib/file-tester.js
CHANGED
|
@@ -27,10 +27,7 @@ function parseExpectation(expectation) {
|
|
|
27
27
|
return [new Rule(null, expectation)];
|
|
28
28
|
case "object":
|
|
29
29
|
return Object.keys(expectation).map(function (path) {
|
|
30
|
-
return new Rule(
|
|
31
|
-
path,
|
|
32
|
-
expectation[path] === true ? null : expectation[path]
|
|
33
|
-
);
|
|
30
|
+
return new Rule(path, expectation[path] === true ? null : expectation[path]);
|
|
34
31
|
});
|
|
35
32
|
default:
|
|
36
33
|
throw new TypeError("Unknown expectation type");
|
|
@@ -72,7 +69,7 @@ FileTester.prototype.test = function (file, callback) {
|
|
|
72
69
|
} else {
|
|
73
70
|
callback();
|
|
74
71
|
}
|
|
75
|
-
}
|
|
72
|
+
},
|
|
76
73
|
);
|
|
77
74
|
};
|
|
78
75
|
|
|
@@ -119,8 +116,7 @@ Rule.wrapTester = function (tester) {
|
|
|
119
116
|
return wrapAssertion(tester);
|
|
120
117
|
}
|
|
121
118
|
|
|
122
|
-
var stringTester =
|
|
123
|
-
tester instanceof StringTester ? tester : new StringTester(tester);
|
|
119
|
+
var stringTester = tester instanceof StringTester ? tester : new StringTester(tester);
|
|
124
120
|
var streamTester = new StreamTester(stringTester);
|
|
125
121
|
return function (file, callback) {
|
|
126
122
|
if (file.isNull()) {
|
package/lib/stream-tester.js
CHANGED
|
@@ -19,11 +19,15 @@ StreamTester.prototype.test = function (stream, callback) {
|
|
|
19
19
|
return stream
|
|
20
20
|
.pipe(spyStream)
|
|
21
21
|
.on("error", function (err) {
|
|
22
|
-
|
|
22
|
+
if (!yielded) {
|
|
23
|
+
callback(err);
|
|
24
|
+
}
|
|
23
25
|
yielded = true;
|
|
24
26
|
})
|
|
25
27
|
.on("end", function () {
|
|
26
|
-
|
|
28
|
+
if (!yielded) {
|
|
29
|
+
callback(null);
|
|
30
|
+
}
|
|
27
31
|
yielded = true;
|
|
28
32
|
});
|
|
29
33
|
};
|
|
@@ -43,6 +47,6 @@ StreamTester.prototype.createStream = function () {
|
|
|
43
47
|
_this.emit("error", err);
|
|
44
48
|
cb();
|
|
45
49
|
});
|
|
46
|
-
}
|
|
50
|
+
},
|
|
47
51
|
);
|
|
48
52
|
};
|
package/lib/string-tester.js
CHANGED
|
@@ -26,9 +26,12 @@ StringTester.prototype.parseExpectation = function (expectation) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (typeof expectation === "string") {
|
|
29
|
-
return wrapAssertion(
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return wrapAssertion(
|
|
30
|
+
function (target) {
|
|
31
|
+
return target.indexOf(expectation) >= 0;
|
|
32
|
+
},
|
|
33
|
+
"not containing " + JSON.stringify(expectation),
|
|
34
|
+
);
|
|
32
35
|
}
|
|
33
36
|
if (expectation instanceof RegExp) {
|
|
34
37
|
return wrapAssertion(function (target) {
|
package/package.json
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gulp-expect-file",
|
|
3
|
-
"version": "
|
|
4
|
-
"author": "Kota Saito <kotas.nico@gmail.com>",
|
|
5
|
-
"copyright": "2014 Kota Saito",
|
|
3
|
+
"version": "3.0.0",
|
|
6
4
|
"description": "Expect files in pipes for gulp.js",
|
|
7
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"expect",
|
|
7
|
+
"gulpplugin",
|
|
8
|
+
"test"
|
|
9
|
+
],
|
|
8
10
|
"homepage": "https://github.com/pioug/gulp-expect-file/",
|
|
9
11
|
"bugs": "https://github.com/pioug/gulp-expect-file/issues",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Kota Saito <kotas.nico@gmail.com>",
|
|
10
14
|
"repository": {
|
|
11
15
|
"type": "git",
|
|
12
16
|
"url": "git://github.com/pioug/gulp-expect-file.git"
|
|
13
17
|
},
|
|
14
18
|
"main": "index.js",
|
|
15
19
|
"scripts": {
|
|
16
|
-
"test": "node_modules/.bin/mocha"
|
|
20
|
+
"test": "node_modules/.bin/mocha",
|
|
21
|
+
"lint": "oxlint --deny-warnings . --ignore-path .oxignore",
|
|
22
|
+
"format": "oxfmt --write \"**/*.{js,json,yml,yaml,md}\"",
|
|
23
|
+
"format:check": "oxfmt --check \"**/*.{js,json,yml,yaml,md}\""
|
|
17
24
|
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"gulpplugin",
|
|
20
|
-
"test",
|
|
21
|
-
"expect"
|
|
22
|
-
],
|
|
23
25
|
"dependencies": {
|
|
24
26
|
"ansi-colors": "^4.1.1",
|
|
25
27
|
"async": "^3.2.0",
|
|
26
|
-
"fancy-log": "^
|
|
27
|
-
"minimatch": "^
|
|
28
|
-
"plugin-error": "^
|
|
28
|
+
"fancy-log": "^2.0.0",
|
|
29
|
+
"minimatch": "^10.2.2",
|
|
30
|
+
"plugin-error": "^2.0.1",
|
|
29
31
|
"through2": "^4.0.2",
|
|
30
|
-
"vinyl": "^
|
|
32
|
+
"vinyl": "^3.0.1"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"mocha": "^8.4.0",
|
|
35
|
+
"mocha": "^12.0.0-beta-9",
|
|
35
36
|
"mock-require": "^3.0.3",
|
|
36
|
-
"
|
|
37
|
+
"oxfmt": "^0.34.0",
|
|
38
|
+
"oxlint": "^1.49.0",
|
|
37
39
|
"should": "^13.2.3",
|
|
38
40
|
"temp": "^0.9.4"
|
|
39
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=24.0.0"
|
|
44
|
+
},
|
|
45
|
+
"copyright": "2014 Kota Saito"
|
|
40
46
|
}
|