These commands navigate to a specific directory, install a browser automation library, and create three new directories: Collections
, searches
, and screenshots
. The directory creation commands include error handling to ensure the execution continues even if a directory already exists or cannot be created.
npm run import -- "node webdriver support"
cd ~/jupytangular \
&& npm install wdio webdriverio \
&& mkdir ~/Collections || true \
&& mkdir ~/Collections/searches || true \
&& mkdir ~/Collections/screenshots || true
bash
#!/bin/bash
# Set the directory path
JUPYTANGULAR_DIR="~/jupytangular"
# Function to create directory
create_directory() {
local dir_path=$1
if [! -d "$dir_path" ]; then
mkdir -p "$dir_path"
echo "Directory created: $dir_path"
else
echo "Directory already exists: $dir_path"
fi
}
# Create directories
cd "$JUPYTANGULAR_DIR" || exit
echo "Installing dependencies..."
npm install wdio webdriverio
echo "Directories created..."
# Create subdirectories in ~/Collections if they don't exist
create_directory "~/Collections"
create_directory "~/Collections/searches"
create_directory "~/Collections/screenshots"
# TODO: Consider adding error handling for npm install
Code Breakdown
Command 1: cd ~/jupytangular
~/jupytangular
(user's home directory followed by jupytangular
folder)Command 2: npm install wdio webdriverio
wdio
: WebdriverIO, a Node.js library for browser automationwebdriverio
: the same library, possibly installed as a separate packageCommand 3: mkdir ~/Collections || true
Collections
in the user's home directory (~/
)|| true
is a conditional statement that ensures the command continues executing even if the directory creation fails (i.e., returns a non-zero exit code)Command 4: mkdir ~/Collections/searches || true
searches
inside the previously created Collections
directoryCommand 5: mkdir ~/Collections/screenshots || true
screenshots
inside the previously created Collections
directory