@axe-core/cli
Version:
A CLI for accessibility testing using axe-core
51 lines • 2.37 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runCLIWithOptions = void 0;
const execa_1 = __importDefault(require("execa"));
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const TS_NODE = require.resolve('ts-node/dist/bin.js');
const CLI = path_1.default.resolve(__dirname, '..', 'bin', 'cli.ts');
const PROJECT_FILE = path_1.default.join(__dirname, '..', 'tsconfig.json');
/**
* Run the CLI with the given `args`.
*
* Will not reject if the CLI exits with a non-zero exit code. It is expected that you check the `.exitCode` value yourself.
*
* @param args CLI arguments to pass
*/
const runCLI = (...args) => (0, exports.runCLIWithOptions)(args, { reject: false });
exports.default = runCLI;
/**
* Run the CLI with the given `args` and `options`.
*
* Set `DEBUG_CLI_TESTS` for additional debugging support (logging).
*
* @param args CLI arguments to pass
* @param options Options for `execa`
*/
const runCLIWithOptions = (args, options) => __awaiter(void 0, void 0, void 0, function* () {
if ('DEBUG_CLI_TESTS' in process.env) {
console.log('cli', args.join(' '));
}
const result = yield (0, execa_1.default)(TS_NODE, [CLI, ...args], options);
if ('DEBUG_CLI_TESTS' in process.env) {
fs_1.default.writeFileSync('./stdout.txt', result.stdout);
fs_1.default.writeFileSync('./stderr.txt', result.stderr);
}
return result;
});
exports.runCLIWithOptions = runCLIWithOptions;
//# sourceMappingURL=index.js.map