diff --git a/package.json b/package.json index f67a3dfb..8ca1604e 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,14 @@ "url": "https://github.com/nodenv/node-build-prerelease/issues" }, "files": [ + "script", "share" ], "directories": { - "test": "./test" + "test": "test" }, "scripts": { + "postinstall": "script/postinstall", "posttest": "npm run lint", "lint": "git ls-files bin script **/*.*sh | xargs shellcheck", "verify-definitions": "scripty", diff --git a/script/postinstall b/script/postinstall new file mode 100755 index 00000000..ce61e13f --- /dev/null +++ b/script/postinstall @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -euo pipefail +IFS=$'\n\t' + +installed_by_name() { + local pattern='"remain":\["'${npm_package_name-} + + [[ ${npm_config_argv-} =~ $pattern ]] +} + +if [ -n "${npm_config_argv-}" ] && ! installed_by_name; then + exit +fi + +cat <<-MSG +==================== +${npm_package_name-} caveats: + +For \`node-build\`/\`nodenv install\` to pick up definitions provided by this plugin, +ensure '$PWD/share/node-build' exists in NODE_BUILD_DEFINITIONS. + export NODE_BUILD_DEFINITIONS="$PWD/share/node-build" +==================== +MSG