Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://EditorConfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -e
cd "$(dirname "$0")"

if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
PREFIX="/usr/local"
fi

SHARE_PATH="${PREFIX}/share/node-build"
Expand Down
18 changes: 9 additions & 9 deletions script/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ set -euo pipefail
IFS=$'\n\t'

installed_by_name() {
local pattern='"remain":\["'${npm_package_name-}
local pattern='"remain":\["'${npm_package_name-}

[[ ${npm_config_argv-} =~ $pattern ]]
[[ ${npm_config_argv-} =~ $pattern ]]
}

if [ -n "${npm_config_argv-}" ] && ! installed_by_name; then
exit
exit
fi

cat <<-MSG
====================
${npm_package_name-} caveats:
====================
${npm_package_name-} caveats:

For \`node-build\`/\`nodenv install\` to pick up definitions provided by this plugin,
ensure share/node-build directory exists in NODE_BUILD_DEFINITIONS:
export NODE_BUILD_DEFINITIONS="$PWD/share/node-build"
====================
For \`node-build\`/\`nodenv install\` to pick up definitions provided by this plugin,
ensure share/node-build directory exists in NODE_BUILD_DEFINITIONS:
export NODE_BUILD_DEFINITIONS="$PWD/share/node-build"
====================
MSG
40 changes: 20 additions & 20 deletions script/preversion
Original file line number Diff line number Diff line change
Expand Up @@ -21,59 +21,59 @@ set -euo pipefail

unset verbose strict
while getopts "ov" opt; do
case "$opt" in
o) strict=1 ;;
v) verbose=1 ;;
*) break ;;
esac
case "$opt" in
o) strict=1 ;;
v) verbose=1 ;;
*) break ;;
esac
done
shift $((OPTIND - 1))

if [ "${1-}" = -- ]; then
shift
shift
fi

abort() {
echo "Aborting: $1" >&2
exit "${2:-1}"
echo "Aborting: $1" >&2
exit "${2:-1}"
}

declare -a files
if [ "$#" -gt 0 ]; then
files=("$@")
files=("$@")
else
IFS=" " read -r -a files <<<"$(node -p 'require("./package").files.join(" ")')"
IFS=" " read -r -a files <<<"$(node -p 'require("./package").files.join(" ")')"
fi

git fetch --quiet --tags origin main

existing="$(git tag --points-at HEAD)"
if [ -n "$existing" ]; then
abort "HEAD is already tagged as '${existing}'"
abort "HEAD is already tagged as '${existing}'"
fi

current_branch="$(git symbolic-ref --short HEAD)"
if [ "$current_branch" != main ]; then
abort "Not currently on main branch" 2
abort "Not currently on main branch" 2
fi

previous_tag="$(git describe --tags --abbrev=0)"
if git diff --quiet "${previous_tag}..HEAD" -- "${files[@]}"; then
abort "No features to release since '${previous_tag}'"
abort "No features to release since '${previous_tag}'"
fi

allowed_changes=("${files[@]}" .github script *.md)
allowed_changes=("${allowed_changes[@]/#/\':!\'}") # prefix pathspecs with git's "ignore"

if [ -n "${strict-}" ] &&
! git diff --quiet "${previous_tag}..HEAD" -- "${allowed_changes[@]}"; then
{
echo "git diff --stat ${previous_tag}..HEAD -- ${allowed_changes[*]}"
git diff --stat "${previous_tag}..HEAD" -- "${allowed_changes[@]}"
} >&2
abort "Changes detected outside '${allowed_changes[*]#:!}'" 2
! git diff --quiet "${previous_tag}..HEAD" -- "${allowed_changes[@]}"; then
{
echo "git diff --stat ${previous_tag}..HEAD -- ${allowed_changes[*]}"
git diff --stat "${previous_tag}..HEAD" -- "${allowed_changes[@]}"
} >&2
abort "Changes detected outside '${allowed_changes[*]#:!}'" 2
fi

if [ -n "${verbose-}" ]; then
git log "$previous_tag"... --oneline -- "${files[@]}"
git log "$previous_tag"... --oneline -- "${files[@]}"
fi