Skip to content

Instantly share code, notes, and snippets.


Rob Crawford robCrawford

  • London, UK
View GitHub Profile
robCrawford /
Last active Oct 16, 2020
Copies a directory from the current package into node_modules of a parent package
cp-dep() {
# Copy directory named $1 in current package to node_modules of package named $2
# e.g. `cp-dep lib my-parent-app`
cd $(git rev-parse --show-toplevel)
package=$(node -p -e "require('./package.json').name")
dependency="$(cd .. && pwd)/$2/node_modules/$package"
if [ -d $1 ] && [ -d $dependency ]; then
rm -rf $to && cp -r $1 $to
echo "Copied '$1' to '$to'"
robCrawford /
Last active Jun 25, 2020
Open a PR in VS Code
# Loads a feature branch as unstaged changes to master and opens the files in VS Code.
# Usage: `code-pr feature-branch`
# Does not run if working directory is not clean.
# `code-pr -r` resets working directory and returns to previous branch/directory
code-pr() {
if [ "$1" = "-r" ]; then
prePr="$(git rev-parse --abbrev-ref HEAD)";
if [ -z "$(git status --porcelain)" ]; then
robCrawford /
Last active Nov 20, 2020
Hard link JS files in a node_modules package to another location