Skip to content

Commit

Permalink
DQA-9542: AXE Scanner command fails on 1st attempt (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocsilva authored Jun 7, 2024
1 parent 7a7aa2e commit 9756040
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/TaskRunner/Commands/AxeCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,27 @@ public function toolkitSetupAxeScan()
// Apply temporary patch to axe-scan when starting puppeteer to have the
// option --no-sandbox, this avoids the error: Running as root without
// --no-sandbox is not supported.
$files = [
'node_modules/axe-scan/build/src/commands/run.js',
'node_modules/axe-scan/build/src/commands/summary.js',
];
$from = 'const browser = await puppeteer.launch();';
$args = '["--no-sandbox", "--disable-setuid-sandbox", "--single-process", "--disable-impl-side-painting", "--disable-gpu-sandbox", "--disable-accelerated-2d-canvas", "--disable-accelerated-jpeg-decoding", "--disable-dev-shm-usage"]';
$to = 'const browser = await puppeteer.launch({args: ' . $args . '});';
foreach ($files as $file) {
if (file_exists($file)) {
$tasks[] = $this->taskReplaceInFile($file)->from($from)->to($to);
$tasks[] = $this->collectionBuilder()->addCode(function () {
$files = [
'node_modules/axe-scan/build/src/commands/run.js',
'node_modules/axe-scan/build/src/commands/summary.js',
];
$from = 'const browser = await puppeteer.launch();';
$args = '["--no-sandbox", "--disable-setuid-sandbox", "--single-process", "--disable-impl-side-painting", "--disable-gpu-sandbox", "--disable-accelerated-2d-canvas", "--disable-accelerated-jpeg-decoding", "--disable-dev-shm-usage"]';
$to = 'const browser = await puppeteer.launch({args: ' . $args . '});';
foreach ($files as $file) {
if (file_exists($file)) {
$this->taskReplaceInFile($file)->from($from)->to($to)->run();
}
}
}
});

// Make sure puppeteer is installed.
if (file_exists('node_modules/puppeteer/install.mjs')) {
$tasks[] = $this->taskExec('node node_modules/puppeteer/install.mjs');
}
$tasks[] = $this->collectionBuilder()->addCode(function () {
if (file_exists('node_modules/puppeteer/install.mjs')) {
$this->_exec('node node_modules/puppeteer/install.mjs');
}
});

return $this->collectionBuilder()->addTaskList($tasks);
}
Expand Down

0 comments on commit 9756040

Please sign in to comment.