UNPKG

855 BJavaScriptView Raw
1"use strict";
2
3var systemPath = require("path");
4
5var mm = require("micromatch");
6
7var tsDeclarationExtTest = /\.d\.tsx?$/;
8var jsonYamlExtTest = /\.(json|ya?ml)$/; // https://github.com/facebook/jest/blob/v24.0.0-alpha.4/packages/jest-config/src/Defaults.js#L71
9
10function isTestFile(filePath) {
11 var testPatterns = ["**/__tests__/**/*.(js|ts)?(x)", "**/(*.)+(spec|test).(js|ts)?(x)"];
12 return mm.isMatch(filePath, testPatterns);
13}
14
15module.exports = function (path) {
16 // Disallow paths starting with an underscore (_) or dot (.)
17 // and template-.
18 // and .d.ts
19 var parsedPath = systemPath.parse(path);
20 return parsedPath.name.slice(0, 1) !== "_" && parsedPath.name.slice(0, 1) !== "." && parsedPath.name.slice(0, 9) !== "template-" && !tsDeclarationExtTest.test(parsedPath.base) && !jsonYamlExtTest.test(parsedPath.base) && !isTestFile(path);
21};
\No newline at end of file