Skip to content

Commit 04283ac

Browse files
committed
Cleanup some stuff
1 parent 8401f8a commit 04283ac

File tree

5 files changed

+13
-28
lines changed

5 files changed

+13
-28
lines changed

api.js

+3-21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var Promise = require('bluebird');
88
var figures = require('figures');
99
var globby = require('globby');
1010
var chalk = require('chalk');
11+
var commondir = require('commondir');
1112
var resolveCwd = require('resolve-cwd');
1213
var fork = require('./lib/fork');
1314
var formatter = require('./lib/enhance-assert').formatter();
@@ -100,25 +101,6 @@ Api.prototype._handleTest = function (test) {
100101
this.emit('test', test);
101102
};
102103

103-
Api.prototype._findBase = function (files) {
104-
this.base = files.reduce(function (base, file) {
105-
file = path.relative('.', file);
106-
file = file.split(path.sep);
107-
if (base === false) {
108-
return file;
109-
}
110-
return base.filter(function (part, i) {
111-
return file[i].toLowerCase() === part.toLowerCase();
112-
});
113-
}, false).join(path.sep);
114-
115-
if (this.base === '' || this.base === '.') {
116-
this.base = this.files[0] || 'test';
117-
}
118-
119-
this.base += path.sep;
120-
};
121-
122104
Api.prototype._prefixTitle = function (file) {
123105
if (this.fileCount === 1) {
124106
return '';
@@ -156,7 +138,7 @@ Api.prototype.run = function () {
156138

157139
self.fileCount = files.length;
158140

159-
self._findBase(files);
141+
self.base = path.relative('.', commondir('.', files)) + path.sep;
160142

161143
var tests = files.map(self._runFile);
162144

@@ -210,7 +192,7 @@ function handlePaths(files) {
210192
files = [
211193
'test.js',
212194
'test-*.js',
213-
'test/*.js'
195+
'test'
214196
];
215197
}
216198

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"cacha": "^1.0.3",
9090
"chalk": "^1.0.0",
9191
"co-with-promise": "^4.6.0",
92+
"commondir": "^1.0.1",
9293
"core-assert": "^0.1.0",
9394
"debug": "^2.2.0",
9495
"deeper": "^2.1.0",

test/fixture/subdir/failing-subdir.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
var test = require('../../../');
1+
import test from '../../../';
22

3-
test('subdir fail', function (t) {
3+
test('subdir fail', t => {
44
t.fail();
55
});
6-
7-
8-

test/fixture/subdir/in-a-subdir.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var test = require('../../../');
1+
import test from '../../../';
22

3-
test('subdir', function (t) {
3+
test('subdir', t => {
44
t.pass();
55
});

test/fixture/subdir/nested/nested.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import test from '../../../../';
2+
3+
test('subdir', t => {
4+
t.pass();
5+
});

0 commit comments

Comments
 (0)