The script automates the process of cleaning up development-related directories, improving workspace organization and freeing up disk space. It supports the following features:
-
Directory Scanning:
- Scans a specified directory (or the current directory if no argument is provided) for
node_modulesandvendorfolders.
- Scans a specified directory (or the current directory if no argument is provided) for
-
Selective Deletion:
node_modules: Removes allnode_modulesdirectories recursively within the specified path.vendor: Removesvendordirectories only if acomposer.jsonfile exists in the same level, ensuring it's part of a valid PHP project.
-
Interactive Feedback:
- Displays an animated loading spinner during each deletion process, making the script visually engaging and informative.
-
Error Handling:
- Validates the existence of the specified directory and provides user-friendly error messages if issues are detected.
-
Usage Help:
- Includes a help option (
-hor--help) that explains how to use the script.
- Includes a help option (
-
Cross-Platform Compatibility:
- Compatible with Unix-based systems, including Linux and macOS.
-
Save the script to a file, e.g.,
cleanup.sh. -
Grant execution permissions:
chmod +x cleanup.sh
-
Execute the script, providing a directory path (optional):
./cleanup.sh /path/to/project
If no path is specified, the current directory will be scanned.
-
For help, run:
./cleanup.sh -h