Skip to content

Add a wrapper script to keep ./solcjs working #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 13 additions & 0 deletions solcjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -e

# Wrapper script for backwards compatibility with the old repo structure.
#
# NOTE: It's recommended to run `npx solcjs` instead if you're installing solc-js as an npm package.
# Or, if you're using the repository directly, you should switch to `dist/solc.js`.

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"

[ -e dist/solc.js ] || npm run build
exec dist/solc.js "$@" < /dev/stdin
Comment on lines +9 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do it like that, the change will persist until after the script has run, which is also weird.
What about

Suggested change
script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"
[ -e dist/solc.js ] || npm run build
exec dist/solc.js "$@" < /dev/stdin
script_dir="$(cd "$(dirname "$0")" && pwd)"
(
cd "$script_dir"
[ -e dist/solc.js ] || npm run build
exec dist/solc.js "$@" < /dev/stdin
)

(not sure if we have to repeat the set comamand)