Skip to content

Commit

Permalink
Fix as per CI
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Jun 27, 2023
1 parent e08d319 commit c4ceb23
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
- name: plugin-test
uses: asdf-vm/actions/plugin-test@v2
with:
command: node_modules/.bin/markdownlint-cli2 _version
command: markdownlint-cli2 _version
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Also, for testing locally use:
# it from failing while trying to lint an inexisting file, while allowing it to self-test
# Replace <user> with your GitHub user name
# Replace <branch> with the branch you pushed
asdf plugin test markdownlint-cli2 https://github.com/<user>/asdf-markdownlint-cli2.git "node_modules/.bin/markdownlint-cli2 _version" --asdf-plugin-gitref <branch>
asdf plugin test markdownlint-cli2 https://github.com/<user>/asdf-markdownlint-cli2.git "markdownlint-cli2 _version" --asdf-plugin-gitref <branch>
```
<!-- markdownlint-enable -->

Expand Down
35 changes: 30 additions & 5 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

GH_REPO="https://github.com/DavidAnson/markdownlint-cli2"
TOOL_NAME="markdownlint-cli2"
BASE_TOOL="node_modules/.bin/markdownlint-cli2"
BASE_TOOL="markdownlint-cli2"
TOOL_TEST="$BASE_TOOL _version"

fail() {
Expand Down Expand Up @@ -33,12 +33,32 @@ list_all_versions() {
list_github_tags
}

ensure() {
local check=$1
local msg=$2
local res

eval "$check" >/dev/null
res=$?
[ "$res" == "0" ] || fail "$msg (${check} == $res)"
}

ensure_node() {
ensure "which node" "it appears node is not available"
}

ensure_npm() {
ensure "which npm" "it appears npm is not available"
}

download_release() {
local version destination
version="$1"
destination="$2"

printf "* Downloading %s release %s...\n" "$TOOL_NAME" "$version"
ensure_node
ensure_npm
npm pack --silent "${TOOL_NAME}@${version}" --pack-destination "$destination" >/dev/null
}

Expand All @@ -52,14 +72,19 @@ install_version() {
fi

(
mkdir -p "$install_path"
cd "$install_path"
mkdir -p "$install_path/bin"

cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"
npm --silent install markdownlint-cli2 --save-dev >/dev/null
ensure_node
ensure_npm
npm --silent install --prefix "$install_path" markdownlint-cli2 --save-dev >/dev/null

local tool_cmd
tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)"
tool_cmd="bin/$(echo "$TOOL_TEST" | cut -d' ' -f1)"

ln -s "$install_path/node_modules/.bin/$BASE_TOOL" "$install_path/$tool_cmd"
chmod +x "$install_path/$tool_cmd"

test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."

echo "$TOOL_NAME $version installation was successful!"
Expand Down

0 comments on commit c4ceb23

Please sign in to comment.