mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
27 lines
721 B
JavaScript
27 lines
721 B
JavaScript
import _ from 'underscore';
|
|
import { pathSep } from '../fs/files';
|
|
|
|
// We have two things "tests" and "app-tests".
|
|
export const TEST_FILENAME_REGEXPS = [
|
|
// "*.test[s].*" or "*.spec[s].*"
|
|
/\.tests?./,
|
|
/\.specs?./,
|
|
];
|
|
|
|
export const APP_TEST_FILENAME_REGEXPS = [
|
|
// "*.app-tests.*" or "*.app-specs.*"
|
|
/\.app-tests?./,
|
|
/\.app-specs?./,
|
|
];
|
|
|
|
// Given a path to a file in an app (relative to the app root
|
|
// directory), is this file a test file?
|
|
export function isTestFilePath(path) {
|
|
const splitPath = path.split(pathSep);
|
|
|
|
// Does the filename match one of the test filename forms?
|
|
return _.any(
|
|
[...TEST_FILENAME_REGEXPS, ...APP_TEST_FILENAME_REGEXPS],
|
|
regexp => regexp.test(_.last(splitPath)));
|
|
}
|