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 9.0.0 to 10.0.0

77

index.js

@@ -1,19 +0,27 @@

'use strict';
const dargs = require('dargs');
const execa = require('execa');
const PluginError = require('plugin-error');
const supportsColor = require('supports-color');
const through = require('through2');
const utils = require('./utils.js');
import process from 'node:process';
import {fileURLToPath} from 'node:url';
import path from 'node:path';
import dargs from 'dargs';
import {execa} from 'execa';
import supportsColor from 'supports-color';
import {gulpPlugin} from 'gulp-plugin-extras';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Mocha options that can be specified multiple times
const MULTIPLE_OPTS = new Set([
'require'
const MULTIPLE_OPTIONS = new Set([
'require',
]);
module.exports = options => {
function convertObjectToList(object) {
return Object.entries(object)
.map(([key, value]) => `${key}=${value}`)
.join(',');
}
export default function gulpMocha(options) {
options = {
colors: Boolean(supportsColor.stdout),
suppress: false,
...options
...options,
};

@@ -23,3 +31,3 @@

if (Array.isArray(value)) {
if (!MULTIPLE_OPTS.has(key)) {
if (!MULTIPLE_OPTIONS.has(key)) {
// Convert arrays into comma separated lists

@@ -30,9 +38,9 @@ options[key] = value.join(',');

// Convert an object into comma separated list
options[key] = utils.convertObjectToList(value);
options[key] = convertObjectToList(value);
}
}
const args = dargs(options, {
const arguments_ = dargs(options, {
excludes: ['suppress'],
ignoreFalse: true
ignoreFalse: true,
});

@@ -42,18 +50,9 @@

function aggregate(file, encoding, done) {
if (file.isStream()) {
done(new PluginError('gulp-mocha', 'Streaming not supported'));
return;
}
return gulpPlugin('gulp-mocha', file => {
files.push(file.path);
done();
}
function flush(done) {
(async () => {
const subprocess = execa('mocha', files.concat(args), {
}, {
async * onFinish(stream) { // eslint-disable-line require-yield
const subprocess = execa('mocha', [...files, ...arguments_], {
localDir: __dirname,
preferLocal: true
preferLocal: true,
});

@@ -68,12 +67,14 @@

const result = await subprocess;
this.emit('_result', result);
stream.emit('_result', result);
} catch (error) {
this.emit('error', new PluginError('gulp-mocha', error.exitCode > 0 ? 'There were test failures' : error));
if (error.exitCode > 0) {
const error = new Error('There were test failures');
error.isPresentable = true;
throw error;
}
throw error;
}
done();
})();
}
return through.obj(aggregate, flush);
};
},
});
}
{
"name": "gulp-mocha",
"version": "9.0.0",
"version": "10.0.0",
"description": "Run Mocha tests",

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

},
"type": "module",
"exports": "./index.js",

@@ -22,4 +23,3 @@ "engines": {

"files": [
"index.js",
"utils.js"
"index.js"
],

@@ -41,15 +41,14 @@ "keywords": [

"dependencies": {
"dargs": "^7.0.0",
"execa": "^5.0.0",
"dargs": "^8.1.0",
"execa": "^8.0.1",
"gulp-plugin-extras": "^0.3.0",
"mocha": "^10.2.0",
"plugin-error": "^1.0.1",
"supports-color": "^8.1.1",
"through2": "^4.0.2"
"supports-color": "^9.4.0"
},
"devDependencies": {
"ava": "^2.3.0",
"ava": "^5.3.1",
"gulp": "^4.0.2",
"p-event": "^4.2.0",
"p-event": "^6.0.0",
"vinyl": "^3.0.0",
"xo": "^0.37.1"
"xo": "^0.56.0"
},

@@ -56,0 +55,0 @@ "peerDependencies": {

@@ -7,19 +7,17 @@ # gulp-mocha

## Install
```sh
npm install --save-dev gulp-mocha
```
$ npm install --save-dev gulp-mocha
```
## Usage
```js
const gulp = require('gulp');
const mocha = require('gulp-mocha');
import gulp from 'gulp';
import mocha from 'gulp-mocha';
exports.default = () => (
export default () => (
gulp.src('test.js', {read: false})
// `gulp-mocha` needs filepaths so you can't have any plugins before it
// `gulp-mocha` needs file paths so you cannot have any plugins before it.
.pipe(mocha({reporter: 'nyan'}))

@@ -29,3 +27,2 @@ );

## API

@@ -43,15 +40,15 @@

Type: `string`<br>
Default: `bdd`<br>
Values: `bdd` `tdd` `qunit` `exports`
Type: `string`\
Default: `'bdd'`\
Values: `'bdd' | 'tdd' | 'qunit' | 'exports'`
Interface to use.
The interface to use.
##### reporter
Type: `string`<br>
Default: `spec`
Type: `string`\
Default: `spec`\
Values: [Reporters](https://github.com/mochajs/mocha/tree/master/lib/reporters)
Reporter that will be used.
The reporter that will be used.

@@ -62,3 +59,3 @@ This option can also be used to utilize third-party reporters. For example, if you `npm install mocha-lcov-reporter` you can then do use `mocha-lcov-reporter` as value.

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

@@ -76,3 +73,3 @@

Type: `number`<br>
Type: `number`\
Default: `2000`

@@ -84,3 +81,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -92,3 +89,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -112,3 +109,3 @@

Type: `string`<br>
Type: `string`\
Example: `js:babel-core/register`

@@ -118,3 +115,2 @@

## FAQ

@@ -127,3 +123,3 @@

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

@@ -144,3 +140,3 @@ .pipe(mocha())

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

@@ -147,0 +143,0 @@ .pipe(mocha({reporter: 'list', exit: true}))

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