UNPKG

playwright-bdd

Version:
29 lines 1.17 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractTagsFromPath = extractTagsFromPath; const node_path_1 = __importDefault(require("node:path")); const paths_1 = require("./paths"); /** * Extracts all '@'-prefixed tags from a given file path. * * Example: * 'features/@foo-bar/@baz.ts' -> ['@foo-bar', '@baz'] */ function extractTagsFromPath(filePath) { const tags = []; if (!(0, paths_1.belongsToNodeModules)(filePath)) { // for filename take first part before dot to omit extension and sub-extension. const fileNamePart = node_path_1.default.basename(filePath).split('.')[0] || ''; const dirParts = node_path_1.default.dirname(filePath).split(node_path_1.default.sep); [...dirParts, fileNamePart].forEach((part) => { // consider any @-prefixed symbols as tag const partTags = part.match(/@[^@\s]+/g) || []; tags.push(...partTags); }); } return tags; } //# sourceMappingURL=tagsFromPath.js.map