UNPKG

592 BJavaScriptView Raw
1'use strict';
2const path = require('path');
3const figures = require('figures');
4const chalk = require('../chalk').get();
5
6const SEPERATOR = ' ' + chalk.gray.dim(figures.pointerSmall) + ' ';
7
8module.exports = (base, file, title) => {
9 const prefix = file
10 // Only replace base if it is found at the start of the path
11 .replace(base, (match, offset) => offset === 0 ? '' : match)
12 .replace(/\.spec/, '')
13 .replace(/\.test/, '')
14 .replace(/test-/g, '')
15 .replace(/\.js$/, '')
16 .split(path.sep)
17 .filter(p => p !== '__tests__')
18 .join(SEPERATOR);
19
20 return prefix + SEPERATOR + title;
21};