From ecde8a76605ae40c8a399d02d64370952eb15f03 Mon Sep 17 00:00:00 2001 From: Katie Ots Date: Wed, 15 Aug 2018 06:14:07 -0700 Subject: [PATCH] Add ocamlformat shim script to install correct version Reviewed By: jvillard Differential Revision: D9333255 fbshipit-source-id: 7b5de2d61 --- scripts/ocamlformat_shim.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 scripts/ocamlformat_shim.sh diff --git a/scripts/ocamlformat_shim.sh b/scripts/ocamlformat_shim.sh new file mode 100755 index 000000000..312db222f --- /dev/null +++ b/scripts/ocamlformat_shim.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright (c) 2017-present, Facebook, Inc. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# Run ocamlformat, installing the required version via opam if necessary. + +set -x +set -e + +TARGET_VERSION=$(grep version .ocamlformat | cut -d ' ' -f 2) + +if [ -z $TARGET_VERSION ] +then + echo "Could not find .ocamlformat file containing version" + exit 1 +fi + +if [ ! -x "$(command -v ocamlformat)" ] || + [ "$TARGET_VERSION" != "$(ocamlformat --version)" ] +then + opam install "ocamlformat.$TARGET_VERSION" +fi + +ocamlformat "$@"