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

gulp-mocha

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-mocha - npm Package Compare versions

Comparing version 6.0.0 to 7.0.0

60

index.js

@@ -7,8 +7,4 @@ 'use strict';

const through = require('through2');
// TODO: Use execa localDir option when available
const npmRunPath = require('npm-run-path');
const utils = require('./utils');
const HUNDRED_MEGABYTES = 1000 * 1000 * 100;
// Mocha options that can be specified multiple times

@@ -19,23 +15,22 @@ const MULTIPLE_OPTS = new Set([

module.exports = opts => {
opts = Object.assign({
module.exports = options => {
options = {
colors: Boolean(supportsColor.stdout),
suppress: false
}, opts);
suppress: false,
...options
};
for (const key of Object.keys(opts)) {
const val = opts[key];
if (Array.isArray(val)) {
for (const [key, value] of Object.entries(options)) {
if (Array.isArray(value)) {
if (!MULTIPLE_OPTS.has(key)) {
// Convert arrays into comma separated lists
opts[key] = val.join(',');
options[key] = value.join(',');
}
} else if (typeof val === 'object') {
} else if (typeof value === 'object') {
// Convert an object into comma separated list
opts[key] = utils.convertObjectToList(val);
options[key] = utils.convertObjectToList(value);
}
}
const args = dargs(opts, {
const args = dargs(options, {
excludes: ['suppress'],

@@ -59,22 +54,21 @@ ignoreFalse: true

function flush(done) {
const env = npmRunPath.env({cwd: __dirname});
const proc = execa('mocha', files.concat(args), {
env,
maxBuffer: HUNDRED_MEGABYTES
});
(async () => {
const subprocess = execa('mocha', files.concat(args), {
localDir: __dirname
});
proc
.then(result => {
if (!options.suppress) {
subprocess.stdout.pipe(subprocess.stdout);
subprocess.stderr.pipe(subprocess.stderr);
}
try {
const result = await subprocess;
this.emit('_result', result);
done();
})
.catch(err => {
this.emit('error', new PluginError('gulp-mocha', err.code > 0 ? 'There were test failures' : err));
done();
});
} catch (error) {
this.emit('error', new PluginError('gulp-mocha', error.exitCode > 0 ? 'There were test failures' : error));
}
if (!opts.suppress) {
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
}
done();
})();
}

@@ -81,0 +75,0 @@

{
"name": "gulp-mocha",
"version": "6.0.0",
"version": "7.0.0",
"description": "Run Mocha tests",

@@ -13,3 +13,3 @@ "license": "MIT",

"engines": {
"node": ">=6"
"node": ">=8"
},

@@ -38,17 +38,32 @@ "scripts": {

"dependencies": {
"dargs": "^5.1.0",
"execa": "^0.10.0",
"mocha": "^5.2.0",
"npm-run-path": "^2.0.2",
"dargs": "^7.0.0",
"execa": "^2.0.4",
"mocha": "^6.2.0",
"plugin-error": "^1.0.1",
"supports-color": "^5.4.0",
"through2": "^2.0.3"
"supports-color": "^7.0.0",
"through2": "^3.0.1"
},
"devDependencies": {
"ava": "*",
"gulp": "^3.9.1",
"p-event": "^1.0.0",
"ava": "^2.3.0",
"gulp": "^4.0.2",
"p-event": "^4.1.0",
"vinyl": "^2.1.0",
"xo": "*"
"xo": "^0.24.0"
},
"peerDependencies": {
"gulp": ">=4"
},
"xo": {
"ignores": [
"test/fixtures"
],
"rules": {
"ava/no-ignored-test-files": "off"
}
},
"ava": {
"files": [
"test/test.js"
]
}
}

@@ -9,9 +9,3 @@ # gulp-mocha [![Build Status](https://travis-ci.org/sindresorhus/gulp-mocha.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-mocha)

---
<p align="center"><b>🔥 Want to strengthen your core JavaScript skills and master ES6?</b><br>I would personally recommend this awesome <a href="https://ES6.io/friend/AWESOME">ES6 course</a> by Wes Bos. You might also like his <a href="https://ReactForBeginners.com/friend/AWESOME">React course</a>.</p>
---
## Install

@@ -30,3 +24,3 @@

gulp.task('default', () =>
exports.default = () => (
gulp.src('test.js', {read: false})

@@ -41,11 +35,10 @@ // `gulp-mocha` needs filepaths so you can't have any plugins before it

### mocha([options])
### mocha(options?)
#### options
Type: `Object`
Type: `object`
Options are passed directly to the `mocha` binary, so you can use any its [command-line options](http://mochajs.org/#usage) in a camelCased form. Arrays and key/value objects are correctly converted to the comma separated list format Mocha expects. Listed below are some of the more commonly used options:
##### ui

@@ -71,3 +64,3 @@

Type: `Object`<br>
Type: `object`<br>
Example: `{reportFilename: 'index.html'}`

@@ -79,3 +72,3 @@

Type: `Array`
Type: `string[]`

@@ -113,3 +106,3 @@ List of accepted global variable names, example `['YUI']`. Accepts wildcards to match multiple global variables, e.g. `['gulp*']` or even `['*']`. See [Mocha globals option](http://mochajs.org/#globals-option).

Type: `Array`
Type: `string[]`

@@ -133,3 +126,3 @@ Require custom modules before tests are run.

```js
gulp.task('default', () =>
exports.default = () => (
gulp.src('test.js')

@@ -150,3 +143,3 @@ .pipe(mocha())

```js
gulp.task('test', () =>
exports.test = () => (
gulp.src(['test/**/*.js'], {read: false})

@@ -157,6 +150,1 @@ .pipe(mocha({reporter: 'list', exit: true}))

```
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
'use strict';
// TODO: Use `Object.entries` when targeting Node.js 8
function objectEntries(object) {
const entries = [];
for (const key of Object.keys(object)) {
const value = object[key];
entries.push([key, value]);
}
return entries;
}
function convertObjectToList(object) {
return objectEntries(object)
return Object.entries(object)
.reduce((result, current) => result.concat(`${current[0]}=${current[1]}`), [])

@@ -18,0 +6,0 @@ .join(',');

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