Skip to content

Commit

Permalink
chore(internal): allow the build script to be run without yarn instal…
Browse files Browse the repository at this point in the history
…led (#91)
  • Loading branch information
stainless-bot authored and RobertCraigie committed Aug 1, 2023
1 parent 01fe37c commit 9bd2b28
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ set -exuo pipefail

node scripts/check-version.cjs

yarn tsc
RUNNER="yarn"
if ! command -v yarn &> /dev/null; then
RUNNER="npx"
fi

$RUNNER tsc

# Build into dist and will publish the package from there,
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
Expand All @@ -23,10 +28,10 @@ done
node scripts/make-dist-package-json.cjs > dist/package.json

# build to .js/.mjs/.d.ts files
tsc-multi
$RUNNER tsc-multi
# copy over handwritten .js/.mjs/.d.ts files
cp src/_shims/*.{d.ts,js,mjs} dist/_shims
tsc-alias -p tsconfig.build.json
$RUNNER tsc-alias -p tsconfig.build.json
# we need to add exports = module.exports = Anthropic TypeScript to index.js;
# No way to get that from index.ts because it would cause compile errors
# when building .mjs
Expand All @@ -46,7 +51,7 @@ else
find dist -type f -exec sed -i "${REFERENCE_SUBS}" {} +
fi

yarn prettier --loglevel=warn --write .
$RUNNER prettier --loglevel=warn --write .

# make sure that nothing crashes when we require the output CJS or
# import the output ESM
Expand Down
2 changes: 1 addition & 1 deletion examples/cancellation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env yarn tsn -T
#!/usr/bin/env -S npm run tsn -T

import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic();
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env yarn tsn -T
#!/usr/bin/env -S npm run tsn -T

import Anthropic from '@anthropic-ai/sdk';

Expand Down
2 changes: 1 addition & 1 deletion examples/streaming.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env yarn tsn -T
#!/usr/bin/env -S npm run tsn -T

import Anthropic from '@anthropic-ai/sdk';

Expand Down

0 comments on commit 9bd2b28

Please sign in to comment.