From 384f18836d536a4ff18fe18ee8e5d8f5a5c9addd Mon Sep 17 00:00:00 2001 From: Amit Dahan Date: Sun, 29 Mar 2020 10:20:42 +0300 Subject: [PATCH] Format dotfiles versions before comparison (#207) Allows both `.node-version` and `.nvmrc` files to contain the same version, if they're formatted into the same version. i.e. `11.10.0` should equal to `v11.10.0` Closes #206 --- .gitignore | 4 +++- .../almost-matching-dotfiles/.node-version | 1 + feature_tests/almost-matching-dotfiles/.nvmrc | 1 + feature_tests/almost-matching-dotfiles/run.sh | 13 +++++++++++++ library/Dotfiles.re | 2 +- 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 feature_tests/almost-matching-dotfiles/.node-version create mode 100644 feature_tests/almost-matching-dotfiles/.nvmrc create mode 100755 feature_tests/almost-matching-dotfiles/run.sh diff --git a/.gitignore b/.gitignore index 78396a0..6fef430 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ fnm.install .DS_Store *.install .tmp -docs/screen_recording \ No newline at end of file +docs/screen_recording +.idea +.fnmTmp \ No newline at end of file diff --git a/feature_tests/almost-matching-dotfiles/.node-version b/feature_tests/almost-matching-dotfiles/.node-version new file mode 100644 index 0000000..933dbb1 --- /dev/null +++ b/feature_tests/almost-matching-dotfiles/.node-version @@ -0,0 +1 @@ +11.10.0 diff --git a/feature_tests/almost-matching-dotfiles/.nvmrc b/feature_tests/almost-matching-dotfiles/.nvmrc new file mode 100644 index 0000000..6af635d --- /dev/null +++ b/feature_tests/almost-matching-dotfiles/.nvmrc @@ -0,0 +1 @@ +v11.10.0 diff --git a/feature_tests/almost-matching-dotfiles/run.sh b/feature_tests/almost-matching-dotfiles/run.sh new file mode 100755 index 0000000..b5850c2 --- /dev/null +++ b/feature_tests/almost-matching-dotfiles/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#set -e + +eval $(fnm env) +fnm install +fnm use + +echo node --version +if [ "$(node --version)" != "v11.10.0" ]; then + echo "Expected Node version is not v11.10.0!" + exit 1 +fi diff --git a/library/Dotfiles.re b/library/Dotfiles.re index 2972c67..75ebc82 100644 --- a/library/Dotfiles.re +++ b/library/Dotfiles.re @@ -20,7 +20,7 @@ let getVersion = () => { switch (nodeVersion, nvmrc) { | (None, None) => Lwt.fail(Version_Not_Provided) - | (Some(v1), Some(v2)) when v1 != v2 => + | (Some(v1), Some(v2)) when Versions.format(v1) != Versions.format(v2) => Lwt.fail(Conflicting_Dotfiles_Found(v1, v2)) | (Some(version), Some(_)) | (Some(version), None)