@gatling.io/cli
Version:
Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
24 lines (23 loc) • 1.11 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findSimulations = void 0;
const promises_1 = __importDefault(require("fs/promises"));
const findSimulations = async (sourcesFolder) => {
const children = await promises_1.default.readdir(sourcesFolder, { recursive: false });
const simulations = children
.filter((path) => path.endsWith(".gatling.js") || path.endsWith(".gatling.ts"))
.map((path) => ({
path,
name: path.slice(0, -11),
type: path.endsWith(".ts") ? "typescript" : "javascript"
}));
const duplicates = simulations.filter((value, index) => simulations.findIndex((other) => other.name === value.name) !== index);
if (duplicates.length > 0) {
throw Error(`Found ambiguous simulation name(s) ${duplicates.map((s) => s.name)}: found as both *.gatling.js and *.gatling.ts file(s)`);
}
return simulations;
};
exports.findSimulations = findSimulations;