diff --git a/Dockerfile b/Dockerfile index a150a3c1..6c59066b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM node:lts-alpine # Installation of packages for purple-hats and chromium -RUN apk add --no-cache g++ make python3 chromium zip bash git +RUN apk add --no-cache g++ make python3 chromium zip bash git imagemagick WORKDIR /app diff --git a/playwrightAxeGenerator.js b/playwrightAxeGenerator.js index 49d25cec..7910e1fb 100644 --- a/playwrightAxeGenerator.js +++ b/playwrightAxeGenerator.js @@ -20,9 +20,10 @@ const playwrightAxeGenerator = async (domain, randomToken, answers) => { }); if (unsafe.length > 0 ) { - consoleLogger.error("Unsafe expressions detected: '"+ unsafe +"' Please revise " + blacklistedPatternsFilename); - silentLogger.error("Unsafe expressions detected: '"+ unsafe +"' Please revise " + blacklistedPatternsFilename); - process.exit(1); + let unsafeExpressionsError = "Unsafe expressions detected: '"+ unsafe +"' Please revise " + blacklistedPatternsFilename; + consoleLogger.error(unsafeExpressionsError); + silentLogger.error(unsafeExpressionsError); + process.exit(1); }; } @@ -37,6 +38,7 @@ const playwrightAxeGenerator = async (domain, randomToken, answers) => { import { isSkippedUrl } from './constants/common.js'; import { spawnSync } from 'child_process'; import safe from 'safe-regex'; + import { consoleLogger, silentLogger } from './logs.js'; const blacklistedPatternsFilename = 'exclusions.txt'; @@ -44,7 +46,10 @@ process.env.CRAWLEE_STORAGE_DIR = constants.a11yStorage; const compareExe = getExecutablePath('**/ImageMagick*/bin','compare'); if (!compareExe) { - throw new Error("Could not find ImageMagick compare. Please ensure ImageMagick is installed."); + let ImagMagickNotFoundError = "Could not find ImageMagick compare. Please ensure ImageMagick is installed at current directory."; + consoleLogger.error(ImagMagickNotFoundError); + silentLogger.error(ImagMagickNotFoundError); + process.exit(1); } removeQuarantineFlag('**/ImageMagick*/lib/*.dylib'); @@ -73,10 +78,11 @@ if (fs.existsSync(blacklistedPatternsFilename)) { }); if (unsafe.length > 0 ) { - consoleLogger.error("Unsafe expressions detected: '"+ unsafe +"' Please revise " + blacklistedPatternsFilename); - silentLogger.error("Unsafe expressions detected: '"+ unsafe +"' Please revise " + blacklistedPatternsFilename); + let unsafeExpressionsError = "Unsafe expressions detected: '"+ unsafe +"' Please revise " + blacklistedPatternsFilename; + consoleLogger.error(unsafeExpressionsError); + silentLogger.error(unsafeExpressionsError); process.exit(1); - } + }; } var index = 1; diff --git a/scripts/hats_shell.sh b/scripts/hats_shell.sh index b141fff0..caf52a50 100644 --- a/scripts/hats_shell.sh +++ b/scripts/hats_shell.sh @@ -31,6 +31,15 @@ else export PATH="$PATH_TO_NODE:$PATH" fi +if $(ls ImageMagick-*/bin/compare 1> /dev/null 2>&1) && [ -d purple-hats ]; then + echo "INFO: Set symbolic link to ImageMagick" + ln -sf "$(ls -d $PWD/ImageMagick-*)" "purple-hats/$(ls -d ImageMagick-*)" + + echo "INFO: Set path to ImageMagick" + export PATH="$(ls -d $PWD/ImageMagick-*/bin):$PATH" + +fi + echo "INFO: Path to node: $PATH_TO_NODE" echo "INFO: Removing com.apple.quarantine attributes for required binaries to run"