Skip to content

Commit

Permalink
Drop mkdirp and replace it with fs.mkdirSync (mochajs#4200)
Browse files Browse the repository at this point in the history
- Replace mkdirp with fs.mkdirSync using {recursive: true}
- Drop the dependency mkdirp from Mocha
- Fix version number of docs and package.json
  • Loading branch information
HyunSangHan authored Mar 19, 2020
1 parent c1a8adb commit f87825a
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Follow these steps to get going. If you are having trouble, don't be afraid to [

> PRO TIP: After `npm install`, run `npm start` to see a list of commands which can be run with `npm start <command>` (powered by [nps](https://npm.im/nps)).
1. [Install Node.js 10.x or newer](https://nodejs.org/en/download/).
1. [Install Node.js 10.12.0 or newer](https://nodejs.org/en/download/).
- If you're new to installing Node, a tool like [nvm](https://github.com/creationix/nvm#install-script) can help you manage multiple version installations.
- You will need [Google Chrome](https://www.google.com/chrome/) to run browser-based tests locally.
1. Follow [Github's documentation](https://help.github.com/articles/fork-a-repo/) on setting up Git, forking and cloning.
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _So you wanna build the site?_

## Prerequisites

- Node.js v10.x or greater
- Node.js v10.12.0 or greater

## Development

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ or as a development dependency for your project:
$ npm install --save-dev mocha
```

> As of v8.0.0, Mocha requires Node.js v10.0.0 or newer.
> As of v8.0.0, Mocha requires Node.js v10.12.0 or newer.
## Getting Started

Expand Down
3 changes: 1 addition & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const os = require('os');
const baseBundleDirpath = path.join(__dirname, '.karma');

Expand Down Expand Up @@ -111,7 +110,7 @@ module.exports = config => {
console.error('No SauceLabs credentials present');
}
}
mkdirp.sync(bundleDirpath);
fs.mkdirSync(bundleDirpath, {recursive: true});
} else {
console.error('CI mode disabled');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/cli/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');

exports.command = 'init <path>';

Expand All @@ -24,7 +23,7 @@ exports.builder = yargs =>
exports.handler = argv => {
const destdir = argv.path;
const srcdir = path.join(__dirname, '..', '..');
mkdirp.sync(destdir);
fs.mkdirSync(destdir, {recursive: true});
const css = fs.readFileSync(path.join(srcdir, 'mocha.css'));
const js = fs.readFileSync(path.join(srcdir, 'mocha.js'));
const tmpl = fs.readFileSync(
Expand Down
5 changes: 3 additions & 2 deletions lib/reporters/xunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
var Base = require('./base');
var utils = require('../utils');
var fs = require('fs');
var mkdirp = require('mkdirp');
var path = require('path');
var errors = require('../errors');
var createUnsupportedError = errors.createUnsupportedError;
Expand Down Expand Up @@ -62,7 +61,9 @@ function XUnit(runner, options) {
throw createUnsupportedError('file output not supported in browser');
}

mkdirp.sync(path.dirname(options.reporterOptions.output));
fs.mkdirSync(path.dirname(options.reporterOptions.output), {
recursive: true
});
self.fileStream = fs.createWriteStream(options.reporterOptions.output);
}

Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test": "./test"
},
"engines": {
"node": ">= 10.0.0"
"node": ">= 10.12.0"
},
"scripts": {
"prepublishOnly": "nps test clean build",
Expand All @@ -56,7 +56,6 @@
"js-yaml": "3.13.1",
"log-symbols": "3.0.0",
"minimatch": "3.0.4",
"mkdirp": "0.5.3",
"ms": "2.1.1",
"node-environment-flags": "1.0.6",
"object.assign": "4.1.0",
Expand Down
3 changes: 1 addition & 2 deletions test/integration/file-utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var utils = require('../../lib/utils');
var fs = require('fs');
var path = require('path');
var os = require('os');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');

describe('file utils', function() {
Expand Down Expand Up @@ -119,7 +118,7 @@ describe('file utils', function() {
afterEach(removeTempDir);

function makeTempDir() {
mkdirp.sync(tmpDir);
fs.mkdirSync(tmpDir, {recursive: true});
}

function removeTempDir() {
Expand Down
13 changes: 9 additions & 4 deletions test/reporters/xunit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var EventEmitter = require('events').EventEmitter;
var fs = require('fs');
var os = require('os');
var path = require('path');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var sinon = require('sinon');
var createStatsCollector = require('../../lib/stats-collector');
Expand Down Expand Up @@ -51,12 +50,12 @@ describe('XUnit reporter', function() {
};

describe('when fileStream can be created', function() {
var mkdirpSync;
var fsMkdirSync;
var fsCreateWriteStream;

beforeEach(function() {
sandbox = sinon.createSandbox();
mkdirpSync = sandbox.stub(mkdirp, 'sync');
fsMkdirSync = sandbox.stub(fs, 'mkdirSync');
fsCreateWriteStream = sandbox.stub(fs, 'createWriteStream');
});

Expand All @@ -67,7 +66,13 @@ describe('XUnit reporter', function() {
XUnit.call(fakeThis, runner, options);

var expectedDirectory = path.dirname(expectedOutput);
expect(mkdirpSync.calledWith(expectedDirectory), 'to be true');
expect(
fsMkdirSync.calledWith(expectedDirectory, {
recursive: true
}),
'to be true'
);

expect(fsCreateWriteStream.calledWith(expectedOutput), 'to be true');
});

Expand Down

0 comments on commit f87825a

Please sign in to comment.