Skip to content

Commit c4ceb23

Browse files
Fix as per CI
1 parent e08d319 commit c4ceb23

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
- name: plugin-test
3131
uses: asdf-vm/actions/plugin-test@v2
3232
with:
33-
command: node_modules/.bin/markdownlint-cli2 _version
33+
command: markdownlint-cli2 _version

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Also, for testing locally use:
7070
# it from failing while trying to lint an inexisting file, while allowing it to self-test
7171
# Replace <user> with your GitHub user name
7272
# Replace <branch> with the branch you pushed
73-
asdf plugin test markdownlint-cli2 https://github.com/<user>/asdf-markdownlint-cli2.git "node_modules/.bin/markdownlint-cli2 _version" --asdf-plugin-gitref <branch>
73+
asdf plugin test markdownlint-cli2 https://github.com/<user>/asdf-markdownlint-cli2.git "markdownlint-cli2 _version" --asdf-plugin-gitref <branch>
7474
```
7575
<!-- markdownlint-enable -->
7676

lib/utils.bash

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
GH_REPO="https://github.com/DavidAnson/markdownlint-cli2"
66
TOOL_NAME="markdownlint-cli2"
7-
BASE_TOOL="node_modules/.bin/markdownlint-cli2"
7+
BASE_TOOL="markdownlint-cli2"
88
TOOL_TEST="$BASE_TOOL _version"
99

1010
fail() {
@@ -33,12 +33,32 @@ list_all_versions() {
3333
list_github_tags
3434
}
3535

36+
ensure() {
37+
local check=$1
38+
local msg=$2
39+
local res
40+
41+
eval "$check" >/dev/null
42+
res=$?
43+
[ "$res" == "0" ] || fail "$msg (${check} == $res)"
44+
}
45+
46+
ensure_node() {
47+
ensure "which node" "it appears node is not available"
48+
}
49+
50+
ensure_npm() {
51+
ensure "which npm" "it appears npm is not available"
52+
}
53+
3654
download_release() {
3755
local version destination
3856
version="$1"
3957
destination="$2"
4058

4159
printf "* Downloading %s release %s...\n" "$TOOL_NAME" "$version"
60+
ensure_node
61+
ensure_npm
4262
npm pack --silent "${TOOL_NAME}@${version}" --pack-destination "$destination" >/dev/null
4363
}
4464

@@ -52,14 +72,19 @@ install_version() {
5272
fi
5373

5474
(
55-
mkdir -p "$install_path"
56-
cd "$install_path"
75+
mkdir -p "$install_path/bin"
5776

5877
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"
59-
npm --silent install markdownlint-cli2 --save-dev >/dev/null
78+
ensure_node
79+
ensure_npm
80+
npm --silent install --prefix "$install_path" markdownlint-cli2 --save-dev >/dev/null
6081

6182
local tool_cmd
62-
tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)"
83+
tool_cmd="bin/$(echo "$TOOL_TEST" | cut -d' ' -f1)"
84+
85+
ln -s "$install_path/node_modules/.bin/$BASE_TOOL" "$install_path/$tool_cmd"
86+
chmod +x "$install_path/$tool_cmd"
87+
6388
test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."
6489

6590
echo "$TOOL_NAME $version installation was successful!"

0 commit comments

Comments
 (0)