Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-expect-file

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-expect-file - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

7

index.js

@@ -48,10 +48,9 @@ 'use strict';

function eachFile(file, encoding, done) {
// To fix relative path to be based on cwd (where gulpfile.js exists)
var originalFile = file;
file = originalFile.clone();
file.base = file.cwd;
numTests++;
// To fix relative path to be based on cwd (where gulpfile.js exists)
file = originalFile.clone();
file.base = file.cwd;
var _this = this;

@@ -58,0 +57,0 @@ fileTester.test(file, function (err) {

@@ -17,5 +17,3 @@ 'use strict';

this.rules = parseExpectation(expectation);
if (options && options.checkRealFile) {
this.rules.push(new Rule(null, checkFileExists));
}
this.options = xtend({ checkRealFile: false }, options);
}

@@ -53,2 +51,3 @@

FileTester.prototype.test = function (file, callback) {
var _this = this;
var matchedAny = false;

@@ -62,6 +61,14 @@ async.eachSeries(this.rules, function (rule, next) {

}, function (err) {
if (!err && !matchedAny) {
err = new ExpectationError('unexpected');
if (err) {
return callback(err);
}
callback(err);
if (!matchedAny) {
return callback(new ExpectationError('unexpected'));
}
if (_this.options.checkRealFile) {
checkFileExists(file, callback);
} else {
callback();
}
});

@@ -68,0 +75,0 @@ };

{
"name": "gulp-expect-file",
"version": "0.0.3",
"version": "0.0.4",
"author": "Kota Saito <kotas.nico@gmail.com>",

@@ -5,0 +5,0 @@ "copyright": "2014 Kota Saito",

@@ -55,2 +55,11 @@ var helper = require('./helper');

context('with an empty array', function () {
var tester = new FileTester([]);
it('should always fail as unexpected', function (done) {
var file = createFile('foo.txt');
tester.test(file, done.expectFail('unexpected'));
});
});
context('with a hash of file name key and true', function () {

@@ -158,3 +167,3 @@ var tester = new FileTester({

it('should fail if the file not exists', function (done) {
var tester = new FileTester('notexists.txt', { checkRealFile: true });
var tester = new FileTester('nonexists.txt', { checkRealFile: true });
var file = createFile('nonexists.txt');

@@ -161,0 +170,0 @@ tester.test(file, done.expectFail('not on filesystem'));

@@ -68,2 +68,19 @@ var helper = require('./helper');

context('with empty array', function () {
it('tests no files in stream', function (done) {
gutil.log.expect(/PASS/);
var stream = expect([]);
testStream(stream, done);
stream.end();
});
it('fails if any file is in stream', function (done) {
gutil.log.expect(/FAIL: foo\.txt is unexpected/);
var stream = expect([]);
testStream(stream, done);
stream.write(createFile('foo.txt'));
stream.end();
});
});
context('with { reportUnexpected: true }', function () {

@@ -175,4 +192,11 @@ it('should report unexpected files', function (done) {

});
it('passes with no files', function (done) {
gutil.log.expect(/PASS/);
var stream = expect.real([]);
testStream(stream, done);
stream.end();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc