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 1.0.2 to 2.0.0

13

index.js

@@ -8,3 +8,2 @@ "use strict";

var through = require("through2");
var xtend = require("xtend");
var colors = require("ansi-colors");

@@ -14,3 +13,3 @@

module.exports.real = function(options, expectation) {
module.exports.real = function (options, expectation) {
if (!expectation) {

@@ -20,3 +19,3 @@ expectation = options;

}
options = xtend({ checkRealFile: true }, options);
options = Object.assign({ checkRealFile: true }, options);
return expect(options, expectation);

@@ -34,3 +33,3 @@ };

options = xtend(
options = Object.assign(
{

@@ -42,3 +41,3 @@ reportUnexpected: true,

silent: false,
verbose: false
verbose: false,
},

@@ -67,3 +66,3 @@ options

var _this = this;
fileTester.test(file, function(err) {
fileTester.test(file, function (err) {
if (err && !options.reportUnexpected) {

@@ -142,3 +141,3 @@ if (err instanceof ExpectationError && err.message === "unexpected") {

var missings = rules
.map(function(r) {
.map(function (r) {
return r.toString();

@@ -145,0 +144,0 @@ })

@@ -10,3 +10,2 @@ "use strict";

var async = require("async");
var xtend = require("xtend");

@@ -17,3 +16,3 @@ module.exports = FileTester;

this.rules = parseExpectation(expectation);
this.options = xtend({ checkRealFile: false }, options);
this.options = Object.assign({ checkRealFile: false }, options);
}

@@ -32,3 +31,3 @@

case "object":
return Object.keys(expectation).map(function(path) {
return Object.keys(expectation).map(function (path) {
return new Rule(

@@ -45,3 +44,3 @@ path,

function checkFileExists(file, callback) {
fs.exists(file.path, function(exists) {
fs.exists(file.path, function (exists) {
if (exists) {

@@ -55,3 +54,3 @@ callback();

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

@@ -61,3 +60,3 @@ var matchedAny = false;

this.rules,
function(rule, next) {
function (rule, next) {
if (!rule.matchFilePath(file.relative)) {

@@ -69,3 +68,3 @@ return next(null);

},
function(err) {
function (err) {
if (err) {

@@ -87,4 +86,4 @@ return callback(err);

FileTester.prototype.getUnusedRules = function() {
return this.rules.filter(function(rule) {
FileTester.prototype.getUnusedRules = function () {
return this.rules.filter(function (rule) {
return !rule.isUsed();

@@ -101,3 +100,3 @@ });

Rule.prototype.matchFilePath = function(path) {
Rule.prototype.matchFilePath = function (path) {
if (this.minimatch) {

@@ -110,3 +109,3 @@ return this.minimatch.match(path);

Rule.prototype.testFile = function(file, callback) {
Rule.prototype.testFile = function (file, callback) {
this.used = true;

@@ -120,11 +119,11 @@ if (this.tester) {

Rule.prototype.isUsed = function() {
Rule.prototype.isUsed = function () {
return this.used;
};
Rule.prototype.toString = function() {
Rule.prototype.toString = function () {
return this.path || "(custom)";
};
Rule.wrapTester = function(tester) {
Rule.wrapTester = function (tester) {
if (typeof tester === "function") {

@@ -137,3 +136,3 @@ return wrapAssertion(tester);

var streamTester = new StreamTester(stringTester);
return function(file, callback) {
return function (file, callback) {
if (file.isNull()) {

@@ -140,0 +139,0 @@ callback(new ExpectationError("not read"));

@@ -16,3 +16,3 @@ "use strict";

StreamTester.prototype.test = function(stream, callback) {
StreamTester.prototype.test = function (stream, callback) {
var spyStream = this.createStream();

@@ -22,7 +22,7 @@ var yielded = false;

.pipe(spyStream)
.on("error", function(err) {
.on("error", function (err) {
yielded || callback(err);
yielded = true;
})
.on("end", function() {
.on("end", function () {
yielded || callback(null);

@@ -33,7 +33,7 @@ yielded = true;

StreamTester.prototype.createStream = function() {
StreamTester.prototype.createStream = function () {
var contentsTester = this.contentsTester;
var contents = "";
return through(
function(chunk, encoding, cb) {
function (chunk, encoding, cb) {
contents += chunk.toString();

@@ -43,5 +43,5 @@ this.push(chunk);

},
function(cb) {
function (cb) {
var _this = this;
contentsTester.test(contents, function(err) {
contentsTester.test(contents, function (err) {
_this.emit("error", err);

@@ -48,0 +48,0 @@ cb();

@@ -12,10 +12,10 @@ "use strict";

StringTester.prototype.test = function(target, callback) {
StringTester.prototype.test = function (target, callback) {
this.tester(target, callback);
};
StringTester.prototype.parseExpectation = function(expectation) {
StringTester.prototype.parseExpectation = function (expectation) {
if (expectation instanceof Array) {
var expectations = expectation.map(this.parseExpectation.bind(this));
return function(target, callback) {
return function (target, callback) {
async.applyEachSeries(expectations, target)(callback);

@@ -30,3 +30,3 @@ };

if (typeof expectation === "string") {
return wrapAssertion(function(target) {
return wrapAssertion(function (target) {
return target.indexOf(expectation) >= 0;

@@ -36,3 +36,3 @@ }, "not containing " + JSON.stringify(expectation));

if (expectation instanceof RegExp) {
return wrapAssertion(function(target) {
return wrapAssertion(function (target) {
return expectation.test(target);

@@ -39,0 +39,0 @@ }, "not matching " + expectation.toString());

@@ -5,9 +5,9 @@ "use strict";

module.exports.wrapAssertion = function(func, errorMessage) {
module.exports.wrapAssertion = function (func, errorMessage) {
if (!errorMessage) {
errorMessage = "failed assertion" + (func.name ? " on " + func.name : "");
}
return function(target, callback) {
return function (target, callback) {
var yielded = false;
var castReturn = function(result) {
var castReturn = function (result) {
if (yielded) return;

@@ -14,0 +14,0 @@ if (result === true || result === null || result === undefined) {

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

@@ -25,18 +25,17 @@ "copyright": "2014 Kota Saito",

"ansi-colors": "^4.1.1",
"async": "^3.1.0",
"async": "^3.2.0",
"fancy-log": "^1.3.3",
"minimatch": "^3.0.4",
"plugin-error": "^1.0.1",
"through2": "^3.0.1",
"vinyl": "^2.2.0",
"xtend": "^4.0.2"
"through2": "^4.0.2",
"vinyl": "^2.2.1"
},
"devDependencies": {
"eslint": "^6.7.1",
"mocha": "^6.2.2",
"eslint": "^7.27.0",
"mocha": "^8.4.0",
"mock-require": "^3.0.3",
"prettier": "^1.19.1",
"prettier": "^2.3.0",
"should": "^13.2.3",
"temp": "^0.9.1"
"temp": "^0.9.4"
}
}

@@ -1,2 +0,2 @@

# gulp-expect-file [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
# gulp-expect-file [![NPM version][npm-image]][npm-url] [![Build Status][gh-image]][gh-url] [![Dependency Status][daviddm-image]][daviddm-url]

@@ -22,3 +22,3 @@ > Expectation on generated files for gulp 3/4

gulp.task("copy", function() {
gulp.task("copy", function () {
gulp

@@ -136,3 +136,3 @@ .src(["src/foo.txt"])

.pipe(expect({ errorOnFailure: true }, ["b.txt"]))
.on("error", function(err) {
.on("error", function (err) {
console.error(err);

@@ -162,5 +162,5 @@ });

[npm-image]: https://img.shields.io/npm/v/gulp-expect-file.svg
[travis-url]: https://travis-ci.org/pioug/gulp-expect-file
[travis-image]: https://img.shields.io/travis/pioug/gulp-expect-file.svg
[gh-url]: https://github.com/pioug/gulp-expect-file/actions/workflows/test.yml
[gh-image]: https://github.com/pioug/gulp-expect-file/actions/workflows/test.yml/badge.svg
[daviddm-url]: https://david-dm.org/pioug/gulp-expect-file
[daviddm-image]: https://img.shields.io/david/pioug/gulp-expect-file.svg
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