Skip to content

Instantly share code, notes, and snippets.

Avatar

Rob Crawford robCrawford

  • London, UK
View GitHub Profile
@robCrawford
robCrawford / cp-dep.sh
Last active Oct 16, 2020
Copies a directory from the current package into node_modules of a parent package
View cp-dep.sh
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"
to="$dependency/$1"
if [ -d $1 ] && [ -d $dependency ]; then
rm -rf $to && cp -r $1 $to
echo "Copied '$1' to '$to'"
@robCrawford
robCrawford / code-pr.sh
Last active Jun 25, 2020
Open a PR in VS Code
View code-pr.sh
# 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
code-pr-r
else
prePr="$(git rev-parse --abbrev-ref HEAD)";
if [ -z "$(git status --porcelain)" ]; then
@robCrawford
robCrawford / hardlink.sh
Last active Nov 20, 2020
Hard link JS files in a node_modules package to another location
View hardlink.sh