diff --git a/package.json b/package.json index 2abd85d9b..1a0a4b464 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ "repository": "github:openai/openai-node", "license": "Apache-2.0", "packageManager": "yarn@1.22.21", + "files": [ + "*" + ], "private": false, "scripts": { "test": "bin/check-test-server && yarn jest", @@ -16,7 +19,7 @@ "prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1", "prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1", "format": "prettier --write --cache --cache-strategy metadata . !dist", - "prepare": "if [ $(basename $(dirname $PWD)) = 'node_modules' ]; then npm run build; fi", + "prepare": "if ./scripts/check-is-in-git-install.sh; then npm run build; fi", "tsn": "ts-node -r tsconfig-paths/register", "lint": "eslint --ext ts,js .", "fix": "eslint --fix --ext ts,js ." diff --git a/scripts/check-is-in-git-install.sh b/scripts/check-is-in-git-install.sh new file mode 100755 index 000000000..36bcedc20 --- /dev/null +++ b/scripts/check-is-in-git-install.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Check if you happen to call prepare for a repository that's already in node_modules. +[ "$(basename "$(dirname "$PWD")")" = 'node_modules' ] || +# The name of the containing directory that 'npm` uses, which looks like +# $HOME/.npm/_cacache/git-cloneXXXXXX +[ "$(basename "$(dirname "$PWD")")" = 'tmp' ] || +# The name of the containing directory that 'yarn` uses, which looks like +# $(yarn cache dir)/.tmp/XXXXX +[ "$(basename "$(dirname "$PWD")")" = '.tmp' ]