Skip to content

Commit 9756040

Browse files
authored
DQA-9542: AXE Scanner command fails on 1st attempt (#779)
1 parent 7a7aa2e commit 9756040

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/TaskRunner/Commands/AxeCommands.php

+18-14
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,27 @@ public function toolkitSetupAxeScan()
144144
// Apply temporary patch to axe-scan when starting puppeteer to have the
145145
// option --no-sandbox, this avoids the error: Running as root without
146146
// --no-sandbox is not supported.
147-
$files = [
148-
'node_modules/axe-scan/build/src/commands/run.js',
149-
'node_modules/axe-scan/build/src/commands/summary.js',
150-
];
151-
$from = 'const browser = await puppeteer.launch();';
152-
$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"]';
153-
$to = 'const browser = await puppeteer.launch({args: ' . $args . '});';
154-
foreach ($files as $file) {
155-
if (file_exists($file)) {
156-
$tasks[] = $this->taskReplaceInFile($file)->from($from)->to($to);
147+
$tasks[] = $this->collectionBuilder()->addCode(function () {
148+
$files = [
149+
'node_modules/axe-scan/build/src/commands/run.js',
150+
'node_modules/axe-scan/build/src/commands/summary.js',
151+
];
152+
$from = 'const browser = await puppeteer.launch();';
153+
$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"]';
154+
$to = 'const browser = await puppeteer.launch({args: ' . $args . '});';
155+
foreach ($files as $file) {
156+
if (file_exists($file)) {
157+
$this->taskReplaceInFile($file)->from($from)->to($to)->run();
158+
}
157159
}
158-
}
160+
});
159161

160162
// Make sure puppeteer is installed.
161-
if (file_exists('node_modules/puppeteer/install.mjs')) {
162-
$tasks[] = $this->taskExec('node node_modules/puppeteer/install.mjs');
163-
}
163+
$tasks[] = $this->collectionBuilder()->addCode(function () {
164+
if (file_exists('node_modules/puppeteer/install.mjs')) {
165+
$this->_exec('node node_modules/puppeteer/install.mjs');
166+
}
167+
});
164168

165169
return $this->collectionBuilder()->addTaskList($tasks);
166170
}

0 commit comments

Comments
 (0)