aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/prefix-title.js
blob: a1c7b4f3bc7d313543adeeb1138c7aa72280535f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
const path = require('path');

module.exports = (file, base, separator) => {
	let prefix = file
		// Only replace this.base if it is found at the start of the path
		.replace(base, (match, offset) => offset === 0 ? '' : match)
		.replace(/\.spec/, '')
		.replace(/\.test/, '')
		.replace(/test-/g, '')
		.replace(/\.js$/, '')
		.split(path.sep)
		.filter(p => p !== '__tests__')
		.join(separator);

	if (prefix.length > 0) {
		prefix += separator;
	}

	return prefix;
};