Skip to content

Commit

Permalink
Replace mkdirp with utils.mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunSangHan committed Mar 15, 2020
1 parent 7b2af23 commit bf006f8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions karma.conf.js
Expand Up @@ -2,8 +2,8 @@

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

const hostname = os.hostname();
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = config => {
console.error('No SauceLabs credentials present');
}
}
mkdirp.sync(bundleDirpath);
utils.mkdir(bundleDirpath);
} else {
console.error('CI mode disabled');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/init.js
Expand Up @@ -9,7 +9,7 @@

const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const utils = require('../utils');

exports.command = 'init <path>';

Expand All @@ -24,7 +24,7 @@ exports.builder = yargs =>
exports.handler = argv => {
const destdir = argv.path;
const srcdir = path.join(__dirname, '..', '..');
mkdirp.sync(destdir);
utils.mkdir(destdir);
const css = fs.readFileSync(path.join(srcdir, 'mocha.css'));
const js = fs.readFileSync(path.join(srcdir, 'mocha.js'));
const tmpl = fs.readFileSync(
Expand Down
3 changes: 1 addition & 2 deletions lib/reporters/xunit.js
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,7 @@ function XUnit(runner, options) {
throw createUnsupportedError('file output not supported in browser');
}

mkdirp.sync(path.dirname(options.reporterOptions.output));
utils.mkdir(path.dirname(options.reporterOptions.output));
self.fileStream = fs.createWriteStream(options.reporterOptions.output);
}

Expand Down
2 changes: 1 addition & 1 deletion package-scripts.js
Expand Up @@ -64,7 +64,7 @@ module.exports = {
},
test: {
default: {
script: 'nps lint test.node test.browser test.bundle',
script: 'nps test.node test.browser test.bundle',
description: 'Run all linters and all tests'
},
node: {
Expand Down
3 changes: 1 addition & 2 deletions test/integration/file-utils.spec.js
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);
utils.mkdir(tmpDir);
}

function removeTempDir() {
Expand Down
10 changes: 5 additions & 5 deletions test/reporters/xunit.spec.js
Expand Up @@ -4,7 +4,7 @@ var EventEmitter = require('events').EventEmitter;
var fs = require('fs');
var os = require('os');
var path = require('path');
var mkdirp = require('mkdirp');
var utils = require('../../lib/utils');
var rimraf = require('rimraf');
var sinon = require('sinon');
var createStatsCollector = require('../../lib/stats-collector');
Expand Down Expand Up @@ -43,20 +43,20 @@ describe('XUnit reporter', function() {
});

describe("when 'reporterOptions.output' is provided", function() {
var expectedOutput = path.join(path.sep, 'path', 'to', 'some-output');
var expectedOutput = path.join('path', 'to', 'some-output');
var options = {
reporterOptions: {
output: expectedOutput
}
};

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

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

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

var expectedDirectory = path.dirname(expectedOutput);
expect(mkdirpSync.calledWith(expectedDirectory), 'to be true');
expect(utilsMkdir.calledWith(expectedDirectory), 'to be true');
expect(fsCreateWriteStream.calledWith(expectedOutput), 'to be true');
});

Expand Down

0 comments on commit bf006f8

Please sign in to comment.