-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from JPeer264/feature/refactor-es6
Refactor test.js
- Loading branch information
Showing
1 changed file
with
16 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
var os = require('os') | ||
var path = require('path') | ||
var Mocha = require('mocha') | ||
var assign = require('./lib/util/assign') | ||
var klaw = require('klaw') | ||
'use strict' | ||
|
||
var argv = require('minimist')(process.argv.slice(2)) | ||
const os = require('os') | ||
const path = require('path') | ||
const klaw = require('klaw') | ||
const Mocha = require('mocha') | ||
const assign = require('./lib/util/assign') | ||
|
||
var mochaOpts = assign({ | ||
const argv = require('minimist')(process.argv.slice(2)) | ||
|
||
const mochaOpts = assign({ | ||
ui: 'bdd', | ||
reporter: 'dot', | ||
timeout: 30000 | ||
}, argv) | ||
|
||
var mocha = new Mocha(mochaOpts) | ||
const mocha = new Mocha(mochaOpts) | ||
const testExt = '.test.js' | ||
|
||
klaw('./lib').on('readable', function () { | ||
var item | ||
let item | ||
while ((item = this.read())) { | ||
if (!item.stats.isFile()) return | ||
if (item.path.lastIndexOf('.test.js') !== (item.path.length - '.test.js'.length)) return | ||
if (item.path.lastIndexOf(testExt) !== (item.path.length - testExt.length)) return | ||
mocha.addFile(item.path) | ||
} | ||
}).on('end', function () { | ||
mocha.run(function (failures) { | ||
require('./').remove(path.join(os.tmpdir(), 'fs-extra'), function () { | ||
process.exit(failures) | ||
}) | ||
}).on('end', () => { | ||
mocha.run(failures => { | ||
require('./').remove(path.join(os.tmpdir(), 'fs-extra'), () => process.exit(failures)) | ||
}) | ||
}) |