#!/usr/bin/env bash

# Trick to convert
# `require("bs-react-native*` to `require("bs-react-native/bs-react-native*`
# `from "bs-react-native*` to `from "bs-react-native/bs-react-native*`
# only necessary when you are using git repo as a dep

# sed -i does not work in CI in a docker image on Linux, so let's use ex instead.
ex $1 <<EOF
%s/require("bs-react-native\//require("reason-react-native-monorepo\/bs-react-native\//g
%s/from "bs-react-native\//from "reason-react-native-monorepo\/bs-react-native\//g
%s/require("bs-react-native-jsx3-compat\//require("reason-react-native-monorepo\/bs-react-native-jsx3-compat\//g
%s/from "bs-react-native-jsx3-compat\//from "reason-react-native-monorepo\/bs-react-native-jsx3-compat\//g
%s/require("reason-react-native\//require("reason-react-native-monorepo\/reason-react-native\//g
%s/from "reason-react-native\//from "reason-react-native-monorepo\/reason-react-native\//g
x
EOF

# ex will exit with code 1 if not all the strings are found...
exit 0
