|
| 1 | +function link_package() { |
| 2 | + local package_abs_path=$1 |
| 3 | + local package_name=$2 |
| 4 | + |
| 5 | + echo "Setting up @sentry/${package_name} for linking" |
| 6 | + pushd $package_abs_path |
| 7 | + yarn link |
| 8 | + popd |
| 9 | + |
| 10 | + echo "Linking @sentry/$package_name" |
| 11 | + yarn link "@sentry/$package_name" |
| 12 | + |
| 13 | +} |
| 14 | + |
| 15 | +# Note: LINKED_CLI_REPO and LINKED_PLUGIN_REPO in the functions below should be set to the absolute path of each local repo |
| 16 | + |
| 17 | +function linkcli() { |
| 18 | + if [[ ! $LINKED_CLI_REPO ]]; then |
| 19 | + return |
| 20 | + fi |
| 21 | + |
| 22 | + # check to make sure the repo directory exists |
| 23 | + if [[ -d $LINKED_CLI_REPO ]]; then |
| 24 | + link_package $LINKED_CLI_REPO "cli" |
| 25 | + else |
| 26 | + # the $1 lets us insert a string in that spot if one is passed to `linkcli` (useful for when we're calling this from |
| 27 | + # within another linking function) |
| 28 | + echo "ERROR: Can't link @sentry/cli $1because directory $LINKED_CLI_REPO does not exist." |
| 29 | + fi |
| 30 | +} |
| 31 | + |
| 32 | +function linkplugin() { |
| 33 | + if [[ ! $LINKED_PLUGIN_REPO ]]; then |
| 34 | + return |
| 35 | + fi |
| 36 | + |
| 37 | + # check to make sure the repo directory exists |
| 38 | + if [[ -d $LINKED_PLUGIN_REPO ]]; then |
| 39 | + link_package $LINKED_PLUGIN_REPO "webpack-plugin" |
| 40 | + |
| 41 | + # the webpack plugin depends on `@sentry/cli`, so if we're also using a linked version of the cli package, the |
| 42 | + # plugin needs to link to it, too |
| 43 | + if [[ $LINKED_CLI_REPO ]]; then |
| 44 | + pushd $LINKED_PLUGIN_REPO |
| 45 | + link_cli "in webpack plugin repo " |
| 46 | + popd |
| 47 | + fi |
| 48 | + else |
| 49 | + echo "ERROR: Can't link @sentry/wepack-plugin because $LINKED_PLUGIN_REPO does not exist." |
| 50 | + fi |
| 51 | +} |
0 commit comments