Created
May 28, 2014 04:38
-
-
Save subeeshb/9afe9f2947ce9f486e40 to your computer and use it in GitHub Desktop.
Python script to delete node_modules on windows
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
import os, shutil | |
folders = [] | |
for path, dirs, files in os.walk("./node_modules"): | |
head, tail = os.path.split(path) | |
if tail == 'node_modules': | |
folders.append(path) | |
os.mkdir('./temp_node_modules') | |
for i in range(len(folders)-1, 0, -1): | |
source = folders[i] | |
shutil.move(source, './temp_node_modules') | |
shutil.rmtree('./temp_node_modules/node_modules', ignore_errors=True) | |
shutil.rmtree('./temp_node_modules', ignore_errors=True) | |
shutil.rmtree('./node_modules', ignore_errors=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment