New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

yeoman-assert

Package Overview
Dependencies
Maintainers
7
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yeoman-assert - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

107

index.js

@@ -14,11 +14,32 @@ /**

var fs = require('fs');
var _ = require('lodash');
var pathExists = require('path-exists');
var pathExists = fs.existsSync;
function isFunction(obj) {
return typeof obj === 'function';
}
function isObject(obj) {
return typeof obj === 'object' && obj !== null && obj !== undefined;
}
function extractMethods(methods) {
return _.isArray(methods) ? methods : Object.keys(methods).filter(function (method) {
return _.isFunction(methods[method]);
});
return Array.isArray(methods) ?
methods : Object.keys(methods).filter(function (method) {
return isFunction(methods[method]);
});
}
function convertArgs(args) {
if (args.length > 1) {
return [Array.from(args)];
}
var arg = args[0];
return Array.isArray(arg) ? arg : [arg];
}
function readFile(filename, json) {
var file = fs.readFileSync(filename, 'utf8');
return json ? JSON.parse(file) : file;
}
// Extend the native assert module

@@ -29,3 +50,3 @@ var assert = module.exports = require('assert');

* Assert that a file exists
* @param {String} path - path to a file
* @param {String} path - path to a file
* @example

@@ -43,7 +64,4 @@ * assert.file('templates/user.hbs');

assert.file = function () {
var args = _.toArray(arguments);
args = _.isString(args[0]) ? args : args[0];
args.forEach(function (file) {
var here = pathExists.sync(file);
convertArgs(arguments).forEach(function (file) {
var here = pathExists(file);
assert.ok(here, file + ', no such file or directory');

@@ -55,3 +73,3 @@ });

* Assert that a file doesn't exist
* @param {String} file - path to a file
* @param {String} file - path to a file
* @example

@@ -69,7 +87,4 @@ * assert.noFile('templates/user.hbs');

assert.noFile = function () {
var args = _.toArray(arguments);
args = _.isString(args[0]) ? args : args[0];
args.forEach(function (file) {
var here = pathExists.sync(file);
convertArgs(arguments).forEach(function (file) {
var here = pathExists(file);
assert.ok(!here, file + ' exists');

@@ -81,4 +96,4 @@ });

* Assert that a file's content matches a regex or string
* @param {String} file - path to a file
* @param {Regex|String} reg - regex / string that will be used to search the file
* @param {String} file - path to a file
* @param {Regex|String} reg - regex / string that will be used to search the file
* @example

@@ -101,10 +116,7 @@ * assert.fileContent('models/user.js', /App\.User = DS\.Model\.extend/);

assert.fileContent = function () {
var args = _.toArray(arguments);
var pairs = _.isString(args[0]) ? [args] : args[0];
pairs.forEach(function (pair) {
convertArgs(arguments).forEach(function (pair) {
var file = pair[0];
var regex = pair[1];
assert.file(file);
var body = fs.readFileSync(file, 'utf8');
var body = readFile(file);

@@ -124,4 +136,4 @@ var match = false;

* Assert that a file's content does not match a regex / string
* @param {String} file - path to a file
* @param {Regex|String} reg - regex / string that will be used to search the file
* @param {String} file - path to a file
* @param {Regex|String} reg - regex / string that will be used to search the file
* @example

@@ -143,10 +155,7 @@ * assert.noFileContent('models/user.js', /App\.User = DS\.Model\.extend/);

assert.noFileContent = function () {
var args = _.toArray(arguments);
var pairs = _.isString(args[0]) ? [args] : args[0];
pairs.forEach(function (pair) {
convertArgs(arguments).forEach(function (pair) {
var file = pair[0];
var regex = pair[1];
assert.file(file);
var body = fs.readFileSync(file, 'utf8');
var body = readFile(file);

@@ -164,3 +173,3 @@ if (typeof regex === 'string') {

* Assert that two strings are equal after standardization of newlines
* @param {String} value - a string
* @param {String} value - a string
* @param {String} expected - the expected value of the string

@@ -181,11 +190,9 @@ * @example

* Assert an Object implements an interface
* @param {Object} subject - subject implementing the façade
* @param {Object|Array} methods - a façace, hash or array of keys to be implemented
* @param {Object} subject - subject implementing the façade
* @param {Object|Array} methods - a façace, hash or array of keys to be implemented
*/
assert.implement = function (subject, methods) {
methods = extractMethods(methods);
var pass = methods.filter(function (method) {
return !_.isFunction(subject[method]);
var pass = extractMethods(methods).filter(function (method) {
return !isFunction(subject[method]);
});

@@ -198,11 +205,9 @@

* Assert an Object doesn't implements any method of an interface
* @param {Object} subject - subject not implementing the methods
* @param {Object|Array} methods - hash or array of method names to be implemented
* @param {Object} subject - subject not implementing the methods
* @param {Object|Array} methods - hash or array of method names to be implemented
*/
assert.notImplement = function (subject, methods) {
methods = extractMethods(methods);
var pass = methods.filter(function (method) {
return _.isFunction(subject[method]);
var pass = extractMethods(methods).filter(function (method) {
return isFunction(subject[method]);
});

@@ -215,4 +220,4 @@

* Assert an object contains the provided keys
* @param {Object} obj Object that should match the given pattern
* @param {Object} content An object of key/values the object should contains
* @param {Object} obj Object that should match the given pattern
* @param {Object} content An object of key/values the object should contains
*/

@@ -222,3 +227,3 @@

Object.keys(content).forEach(function (key) {
if (_.isObject(content[key])) {
if (isObject(content[key])) {
assert.objectContent(obj[key], content[key]);

@@ -240,3 +245,3 @@ return;

Object.keys(content).forEach(function (key) {
if (_.isObject(content[key])) {
if (isObject(content[key])) {
assert.noObjectContent(obj[key], content[key]);

@@ -257,4 +262,3 @@ return;

assert.JSONFileContent = assert.jsonFileContent = function (filename, content) {
var obj = JSON.parse(fs.readFileSync(filename, 'utf8'));
assert.objectContent(obj, content);
assert.objectContent(readFile(filename, true), content);
};

@@ -269,4 +273,3 @@

assert.noJSONFileContent = assert.noJsonFileContent = function (filename, content) {
var obj = JSON.parse(fs.readFileSync(filename, 'utf8'));
assert.noObjectContent(obj, content);
assert.noObjectContent(readFile(filename, true), content);
};
{
"name": "yeoman-assert",
"version": "2.2.2",
"version": "2.2.3",
"description": "Assert utility from yeoman",

@@ -26,13 +26,10 @@ "homepage": "http://yeoman.io",

},
"dependencies": {
"lodash": "^3.6.0",
"path-exists": "^2.1.0"
},
"devDependencies": {
"eslint-config-xo-space": "^0.7.0",
"eslint": "^3.15.0",
"eslint-config-xo-space": "^0.15.0",
"gulp": "^3.9.0",
"gulp-eslint": "^1.0.0",
"gulp-eslint": "^3.0.1",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-istanbul": "^0.10.3",
"gulp-mocha": "^2.0.0",
"gulp-istanbul": "^1.1.1",
"gulp-mocha": "^3.0.1",
"gulp-nsp": "^2.1.0",

@@ -39,0 +36,0 @@ "gulp-plumber": "^1.0.0"

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