@@ -144,23 +144,27 @@ public function toolkitSetupAxeScan()
144
144
// Apply temporary patch to axe-scan when starting puppeteer to have the
145
145
// option --no-sandbox, this avoids the error: Running as root without
146
146
// --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
+ }
157
159
}
158
- }
160
+ });
159
161
160
162
// 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
+ });
164
168
165
169
return $ this ->collectionBuilder ()->addTaskList ($ tasks );
166
170
}
0 commit comments