init
This commit is contained in:
40
node_modules/cypress-cucumber-preprocessor/lib/getStepDefinitionsPaths.js
generated
vendored
Normal file
40
node_modules/cypress-cucumber-preprocessor/lib/getStepDefinitionsPaths.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
const path = require("path");
|
||||
const glob = require("glob");
|
||||
const process = require("process");
|
||||
const { getConfig } = require("./getConfig");
|
||||
const stepDefinitionPath = require("./stepDefinitionPath.js");
|
||||
const { getStepDefinitionPathsFrom } = require("./getStepDefinitionPathsFrom");
|
||||
|
||||
const getStepDefinitionsPaths = (filePath) => {
|
||||
const appRoot = process.cwd();
|
||||
let paths = [];
|
||||
const config = getConfig();
|
||||
if (config && config.nonGlobalStepDefinitions) {
|
||||
let nonGlobalPath = getStepDefinitionPathsFrom(filePath);
|
||||
let commonPath = config.commonPath || `${stepDefinitionPath()}/common/`;
|
||||
|
||||
if (config.commonPath) {
|
||||
commonPath = `${path.resolve(appRoot, commonPath)}/`;
|
||||
}
|
||||
|
||||
if (config.nonGlobalStepBaseDir) {
|
||||
const stepBase = `${appRoot}/${config.nonGlobalStepBaseDir}`;
|
||||
nonGlobalPath = nonGlobalPath.replace(stepDefinitionPath(), stepBase);
|
||||
commonPath = `${stepBase}/${config.commonPath || "common/"}`;
|
||||
}
|
||||
|
||||
const nonGlobalPattern = `${nonGlobalPath}/**/*.+(js|ts|tsx)`;
|
||||
|
||||
const commonDefinitionsPattern = `${commonPath}**/*.+(js|ts|tsx)`;
|
||||
paths = paths.concat(
|
||||
glob.sync(nonGlobalPattern),
|
||||
glob.sync(commonDefinitionsPattern)
|
||||
);
|
||||
} else {
|
||||
const pattern = `${stepDefinitionPath()}/**/*.+(js|ts|tsx)`;
|
||||
paths = paths.concat(glob.sync(pattern));
|
||||
}
|
||||
return paths;
|
||||
};
|
||||
|
||||
module.exports = { getStepDefinitionsPaths };
|
Reference in New Issue
Block a user