File tree Expand file tree Collapse file tree
yarn-project/aztec/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,9 +55,21 @@ function echo_yellow {
5555}
5656
5757function timeout {
58- if [ " ${CI:- 0} " = " 1" ] || [ " ${CI:- 0} " = " true" ]; then
58+ if [ " ${CI:- 0} " != " 1" ] && [ " ${CI:- 0} " != " true" ]; then
59+ shift
60+ " $@ "
61+ return
62+ fi
63+ if [ -x /usr/bin/timeout ]; then
64+ # Prefer coreutils `timeout` when available. Absolute path avoids re-entering this function.
5965 /usr/bin/timeout " $@ "
66+ elif perl -e1 2> /dev/null; then
67+ # Fall back to perl's `alarm` when /usr/bin/timeout is missing.
68+ local duration=$1
69+ shift
70+ perl -e " alarm $duration ; exec @ARGV" -- " $@ "
6071 else
72+ # No timeout backend available -- run unguarded rather than fail the install.
6173 shift
6274 " $@ "
6375 fi
Original file line number Diff line number Diff line change @@ -37,16 +37,17 @@ TEMPLATE_DIR="$(dirname $0)/templates/$template"
3737# Copy template crates and substitute placeholders
3838cp -r " $TEMPLATE_DIR /contract" " $contract_dir "
3939cp -r " $TEMPLATE_DIR /test" " $test_dir "
40+ # Use perl -i for portability across os.
4041find " $contract_dir " " $test_dir " -type f -exec \
41- sed -i -e " s/__CRATE_NAME__/${crate_name} /g" -e " s/__AZTEC_VERSION__/${AZTEC_VERSION} /g" {} +
42+ perl -i -pe " s/__CRATE_NAME__/${crate_name} /g; s/__AZTEC_VERSION__/${AZTEC_VERSION} /g" {} +
4243
4344# Add members to workspace Nargo.toml
4445if grep -q ' members\s*=\s*\[\s*\]' Nargo.toml; then
4546 # Empty array: members = []
46- sed -i " s|members\s*=\s*\[\s*\]|members = [\" ${contract_dir} \" , \" ${test_dir} \" ]|" Nargo.toml
47+ perl -i -pe " s|members\s*=\s*\[\s*\]|members = [\" ${contract_dir} \" , \" ${test_dir} \" ]|" Nargo.toml
4748else
4849 # Non-empty array: add before closing ]
49- sed -i " s|\ (members\s*=\s*\[.*\ )\]|\1, \" ${contract_dir} \" , \" ${test_dir} \" ]|" Nargo.toml
50+ perl -i -pe " s|(members\s*=\s*\[.*)\]|\1, \" ${contract_dir} \" , \" ${test_dir} \" ]|" Nargo.toml
5051fi
5152
5253echo " Created crates '${contract_dir} ' and '${test_dir} '"
You can’t perform that action at this time.
0 commit comments