UNPKG

@rbnx/webdriverio

Version:

webdriverio plugin for nx

49 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.unlinkWdioConfig = exports.generateWdioConfig = exports.runWdio = void 0; const devkit_1 = require("@nx/devkit"); const tree_1 = require("nx/src/generators/tree"); const node_child_process_1 = require("node:child_process"); const promises_1 = require("node:fs/promises"); async function runWdio(options) { const { configPath, spec, suite, watch } = options; let command = `${(0, devkit_1.getPackageManagerCommand)().exec} wdio ${configPath}`; if (spec) command += ` --spec=${spec}`; if (suite) command += ` --suite=${suite}`; if (watch) command += ` --watch`; await new Promise((resolve, reject) => { (0, node_child_process_1.exec)(command, {}, (error, stdout, stderr) => { error ? reject(error) : resolve({ stdout, stderr }); }).stdout.pipe(process.stdout); if (watch) { process.on('SIGINT', () => resolve({})); process.on('SIGTERM', () => resolve({})); } }); } exports.runWdio = runWdio; async function generateWdioConfig(tree, options) { const { projectRoot } = options; (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), projectRoot, { tmpl: '', options, }); await (0, devkit_1.formatFiles)(tree); (0, tree_1.flushChanges)(devkit_1.workspaceRoot, tree.listChanges()); } exports.generateWdioConfig = generateWdioConfig; async function unlinkWdioConfig(options) { const { configPath, isVerbose } = options; try { await (0, promises_1.unlink)(configPath); } catch (error) { if (isVerbose) console.error(error); } } exports.unlinkWdioConfig = unlinkWdioConfig; //# sourceMappingURL=run-wdio.js.map