Created
May 15, 2015 13:02
-
-
Save agateau/d1b8b6dfe469dcf30754 to your computer and use it in GitHub Desktop.
A tool to "bisect" Node modules, useful to find out which module is causing failures
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
#!/bin/sh | |
set -e | |
# A tool to "bisect" Node modules, useful to find out which module is causing | |
# failures. | |
# | |
# Given a `node_modules` list known to work and one which is known to be broken, | |
# do the following: | |
# | |
# mkdir /tmp/base_dir | |
# | |
# Copy the working modules: | |
# cp -a node_modules /tmp/base_dir/ok | |
# | |
# Copy the bad modules: | |
# cp -a node_modules /tmp/base_dir/bad | |
# | |
# Create a modules.lst with the following content: | |
# | |
# O module1 | |
# O module2 | |
# O module3 | |
# O module4 | |
# | |
# Run `bisect-modules /tmp/base_dir`: it will copy all modules from | |
# /tmp/base_dir/ok in node_modules | |
# | |
# Edit modules.lst, replace the O in the first column with B (or anything else) | |
# and run `bisect-modules /tmp/base_dir` again to replace the modules marked B | |
# with modules from /tmp/base_dir/bad. Try variations of B and O to find out | |
# which module is causing the failure. | |
modules_base_dir=$1 | |
cat modules.lst | while read ok name ; do | |
if [ "$ok" = "O" ] ; then | |
subdir="ok" | |
else | |
subdir="bad" | |
fi | |
rm -rf node_modules/$name | |
echo cp -a $modules_base_dir/$subdir/$name node_modules | |
cp -a $modules_base_dir/$subdir/$name node_modules | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment