#!/bin/sh # script/add-dependency: add a frontend package, or move one to another # version, with yarn add, which changes package.json and yarn.lock # together; then install from yarn.lock with --frozen-lockfile, as # script/bootstrap does, to show it installs as written. --dev because # no frontend package is needed when the page runs: it ships as the # built dist/. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" usage() { echo "usage: make add-dependency PACKAGE=@" >&2 exit 2 } main() { # Exactly one package. A value beginning with - would reach yarn as # an option; yarn would quietly drop all but the first of several # packages given in one value. [ "$#" -eq 1 ] || usage case "$1" in "" | -* | *[[:space:]]*) usage ;; esac cd "$ROOT" yarn add --dev "$1" yarn install --frozen-lockfile } main "$@"