Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor test.js #375

Merged
merged 1 commit into from
Feb 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions test.js
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))
})
})