
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
gulp-expect-file
Advanced tools
Expectation on generated files for gulp 3/4
This plugin is intended for testing other gulp plugin.
First, install gulp-expect-file
as a development dependency:
npm install --save-dev gulp-expect-file
Then, add it to your gulpfile.js
:
var expect = require("gulp-expect-file");
gulp.task("copy", function () {
gulp
.src(["src/foo.txt"])
.pipe(gulp.dest("dest/"))
.pipe(expect("dest/foo.txt"));
});
Type: String
, Array
, Object
or Function
It describes the expectation of files on pipe.
expectation | meaning |
---|---|
"foo.txt" | Expects foo.txt on pipe |
"*.txt" | Expects any files matching glob *.txt on pipe |
["a.txt", "b.txt"] | Expects a.txt and b.txt both on pipe |
{"a.txt": true, "b.txt": true} | Expects a.txt and b.txt both on pipe (same as above) |
{"foo.txt": "text"} | Expects foo.txt with contents that has "text" as substring |
{"foo.txt": /pattern/} | Expects foo.txt with contents that matches /pattern/ |
function (file) { ... } | Call the tester function for each file on pipe |
{"foo.txt": function (file) { ... }} | Call the tester function for foo.txt |
A tester function is called with vinyl File object of target file.
It can return true
, null
, undefined
for passing that file. false
, String
of error message, or any other value will fail testing on that file.
Sync version:
function (file) {
return /\.txt$/.test(file.path);
}
Async version:
function (file, callback) {
process.nextTick(function () {
if (/\.txt$/.test(file.path)) {
callback('not txt file');
} else {
callback();
}
});
}
Type: Boolean
Default: true
If true, files not matching any expectation will be reported as failure.
For example, if a.txt
and b.txt
are on the pipe, expect(['a.txt'])
will report that b.txt
is unexpected.
gulp.src(["a.txt", "b.txt"]).pipe(expect(["a.txt"]));
// => FAIL: b.txt unexpected
Type: Boolean
Default: true
If true, expected files that are not on the pipe will be reported as failure.
For example, if a.txt
is on the pipe, expect(['a.txt', 'b.txt'])
will report that b.txt
is missing.
gulp.src(["a.txt"]).pipe(expect(["a.txt", "b.txt"]));
// => FAIL: Missing 1 expected files: b.txt
Type: Boolean
Default: false
If true, it also checks if the real file exists on the file system by fs.exists()
.
gulp
.src(["exist.txt", "nonexist.txt"])
.pipe(expect({ checkRealFile: true }, "*.txt"));
// => FAIL: nonexist.txt not exists on filesystem
Type: Boolean
Default: false
If true, it emits error
event when expectations got failed.
gulp
.src(["a.txt"])
.pipe(expect({ errorOnFailure: true }, ["b.txt"]))
.on("error", function (err) {
console.error(err);
});
Type: Boolean
Default: false
If true, it does not report any results.
Type: Boolean
Default: false
If true, it reports files that passed the expectation.
This is just a shortcut for expect({ checkRealFile: true }, expectation)
.
FAQs
Expect files in pipes for gulp.js
The npm package gulp-expect-file receives a total of 3,938 weekly downloads. As such, gulp-expect-file popularity was classified as popular.
We found that gulp-expect-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.