Created
March 17, 2021 14:48
-
-
Save cameronbarker/113e1c519440c916b773a0405e985511 to your computer and use it in GitHub Desktop.
Delete node modules from a folder system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
path = '' # Add folder where all projects live | |
skip_folder = %w[] # Add any folders you'd like to skip | |
Dir.chdir(path) | |
folders = Dir.glob('*').select {|f| File.directory? f} | |
parsed_folders = folders - skip_folder | |
parsed_folders.each do |folder| | |
node_module_path = "#{path}/#{folder}/node_modules" | |
next unless Dir.exist?(node_module_path) | |
puts "Delete node modules from #{folder}" | |
FileUtils.rm_rf(node_module_path) | |
end; nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment