From fcdfc419bb11c0e88f44d1760267a67320b95472 Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Fri, 2 Feb 2024 17:57:22 +0000
Subject: [PATCH] chore(internal): enable building when git installed (#279)

---
 package.json                       | 3 ++-
 scripts/check-is-in-git-install.sh | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100755 scripts/check-is-in-git-install.sh

diff --git a/package.json b/package.json
index 7136495a..a1d8a77f 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
   "repository": "github:anthropics/anthropic-sdk-typescript",
   "license": "MIT",
   "packageManager": "yarn@1.22.21",
+  "files": ["*"],
   "private": false,
   "scripts": {
     "test": "bin/check-test-server && yarn jest",
@@ -16,7 +17,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 00000000..36bcedc2
--- /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' ]