#!/usr/bin/env bash set -euo pipefail if [[ ${OS:-} = Windows_NT ]]; then echo 'error: Please install bun using Windows Subsystem for Linux' exit 1 fi # Reset Color_Off='' # Regular Colors Red='' Green='' Dim='' # White # Bold Bold_White='' Bold_Green='' if [[ -t 1 ]]; then # Reset Color_Off='\033[0m' # Text Reset # Regular Colors Red='\033[0;31m' # Red Green='\033[0;32m' # Green Dim='\033[0;2m' # White # Bold Bold_Green='\033[1;32m' # Bold Green Bold_White='\033[1m' # Bold White fi error() { echo -e "${Red}error${Color_Off}:" "$@" >&2 exit 1 } info() { echo -e "${Dim}$@ ${Color_Off}" } info_bold() { echo -e "${Bold_White}$@ ${Color_Off}" } success() { echo -e "${Green}$@ ${Color_Off}" } command -v unzip >/dev/null || error 'unzip is required to install bun (see: https://github.com/oven-sh/bun#unzip-is-required)' if [[ $# -gt 2 ]]; then error 'Too many arguments, only 2 are allowed. The first can be a specific tag of bun to install. (e.g. "bun-v0.1.4") The second can be a build variant of bun to install. (e.g. "debug-info")' fi case $(uname -ms) in 'Darwin x86_64') target=darwin-x64 ;; 'Darwin arm64') target=darwin-aarch64 ;; 'Linux aarch64' | 'Linux arm64') target=linux-aarch64 ;; 'Linux x86_64' | *) target=linux-x64 ;; esac if [[ $target = darwin-x64 ]]; then # Is this process running in Rosetta? # redirect stderr to devnull to avoid error message when not running in Rosetta if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then target=darwin-aarch64 info "Your shell is running in Rosetta 2. Downloading bun for $target instead" fi fi GITHUB=${GITHUB-"https://github.com"} github_repo="$GITHUB/oven-sh/bun" if [[ $target = darwin-x64 ]]; then # If AVX2 isn't supported, use the -baseline build if [[ $(sysctl -a | grep machdep.cpu | grep AVX2) == '' ]]; then target=darwin-x64-baseline fi fi if [[ $target = linux-x64 ]]; then # If AVX2 isn't supported, use the -baseline build if [[ $(cat /proc/cpuinfo | grep avx2) = '' ]]; then target=linux-x64-baseline fi fi exe_name=bun if [[ $# = 2 && $2 = debug-info ]]; then target=$target-profile exe_name=bun-profile info "You requested a debug build of bun. More information will be shown if a crash occurs." fi if [[ $# = 0 ]]; then bun_uri=$github_repo/releases/latest/download/bun-$target.zip else bun_uri=$github_repo/releases/download/$1/bun-$target.zip fi install_env=BUN_INSTALL bin_env=\$$install_env/bin install_dir=${!install_env:-$HOME/.bun} bin_dir=$install_dir/bin exe=$bin_dir/bun if [[ ! -d $bin_dir ]]; then mkdir -p "$bin_dir" || error "Failed to create install directory \"$bin_dir\"" fi curl --fail --location --progress-bar --output "$exe.zip" "$bun_uri" || error "Failed to download bun from \"$bun_uri\"" unzip -oqd "$bin_dir" "$exe.zip" || error 'Failed to extract bun' mv "$bin_dir/bun-$target/$exe_name" "$exe" || error 'Failed to move extracted bun to destination' chmod +x "$exe" || error 'Failed to set permissions on bun executable' rm -r "$bin_dir/bun-$target" "$exe.zip" tildify() { if [[ $1 = $HOME/* ]]; then local replacement=\~/ echo "${1/$HOME\//$replacement}" else echo "$1" fi } success "bun was installed successfully to $Bold_Green$(tildify "$exe")" if command -v bun >/dev/null; then # Install completions, but we don't care if it fails IS_BUN_AUTO_UPDATE=true $exe completions &>/dev/null || : echo "Run 'bun --help' to get started" exit fi refresh_command='' tilde_bin_dir=$(tildify "$bin_dir") quoted_install_dir=\"${install_dir//\"/\\\"}\" if [[ $quoted_install_dir = \"$HOME/* ]]; then quoted_install_dir=${quoted_install_dir/$HOME\//\$HOME/} fi echo case $(basename "$SHELL") in fish) # Install completions, but we don't care if it fails IS_BUN_AUTO_UPDATE=true SHELL=fish $exe completions &>/dev/null || : commands=( "set --export $install_env $quoted_install_dir" "set --export PATH $bin_env \$PATH" ) fish_config=$HOME/.config/fish/config.fish tilde_fish_config=$(tildify "$fish_config") if [[ -w $fish_config ]]; then { echo -e '\n# bun' for command in "${commands[@]}"; do echo "$command" done } >>"$fish_config" info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_fish_config\"" refresh_command="source $tilde_fish_config" else echo "Manually add the directory to $tilde_fish_config (or similar):" for command in "${commands[@]}"; do info_bold " $command" done fi ;; zsh) # Install completions, but we don't care if it fails IS_BUN_AUTO_UPDATE=true SHELL=zsh $exe completions &>/dev/null || : commands=( "export $install_env=$quoted_install_dir" "export PATH=\"$bin_env:\$PATH\"" ) zsh_config=$HOME/.zshrc tilde_zsh_config=$(tildify "$zsh_config") if [[ -w $zsh_config ]]; then { echo -e '\n# bun' for command in "${commands[@]}"; do echo "$command" done } >>"$zsh_config" info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_zsh_config\"" refresh_command="exec $SHELL" else echo "Manually add the directory to $tilde_zsh_config (or similar):" for command in "${commands[@]}"; do info_bold " $command" done fi ;; bash) commands=( "export $install_env=$quoted_install_dir" "export PATH=$bin_env:\$PATH" ) bash_configs=( "$HOME/.bashrc" "$HOME/.bash_profile" ) if [[ ${XDG_CONFIG_HOME:-} ]]; then bash_configs+=( "$XDG_CONFIG_HOME/.bash_profile" "$XDG_CONFIG_HOME/.bashrc" "$XDG_CONFIG_HOME/bash_profile" "$XDG_CONFIG_HOME/bashrc" ) fi set_manually=true for bash_config in "${bash_configs[@]}"; do tilde_bash_config=$(tildify "$bash_config") if [[ -w $bash_config ]]; then { echo -e '\n# bun' for command in "${commands[@]}"; do echo "$command" done } >>"$bash_config" info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_bash_config\"" refresh_command="source $bash_config" set_manually=false break fi done if [[ $set_manually = true ]]; then echo "Manually add the directory to $tilde_bash_config (or similar):" for command in "${commands[@]}"; do info_bold " $command" done fi ;; *) echo 'Manually add the directory to ~/.bashrc (or similar):' info_bold " export $install_env=$quoted_install_dir" info_bold " export PATH=\"$bin_env:\$PATH\"" ;; esac echo info "To get started, run:" echo if [[ $refresh_command ]]; then info_bold " $refresh_command" fi info_bold " bun --help" 'jarred/exports-map'>jarred/exports-map Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/setTimeout.test.js (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-05-02[bun:ffi] Improve `uint64_t` and `int64_t` performanceGravatar Jarred Sumner 6-227/+512
2022-05-02[bun:ffi] Support `i64` and `u64`Gravatar Jarred Sumner 11-144/+212
2022-05-02[bun:ffi] Support `double` and `float`Gravatar Jarred Sumner 7-65/+65
2022-05-02add a commentGravatar Jarred Sumner 1-0/+13
2022-05-02[bun:ffi] cleanupGravatar Jarred Sumner 21-87/+1051
2022-05-02[bun.js] Add `Bun.nanoseconds()` to report time in nanosGravatar Jarred Sumner 4-146/+145
2022-05-02[bun:ffi] ~20% faster FFI bindings for functions with argumentsGravatar Jarred Sumner 10-13/+220
2022-05-02Automatic CString supportGravatar Jarred Sumner 1-23/+78
2022-05-01[bun:ffi] Add wrapper for type coercionGravatar Jarred Sumner 1-2/+172
2022-05-01wip Buffer.fillGravatar Jarred Sumner 3-95/+167
2022-05-01Buffer.compare & Buffer.equalGravatar Jarred Sumner 2-5/+244
2022-05-01[bun.js] Improve `Buffer` creation perf a littleGravatar Jarred Sumner 2-8/+45
2022-05-01[bun.js] Implement `Buffer.concat`Gravatar Jarred Sumner 2-1/+78
2022-04-30Bump WebKitGravatar Jarred Sumner 1-0/+0
2022-04-30cleanupGravatar Jarred Sumner 5-2/+132
2022-04-30[bun.js] Implement `Buffer.from` and `Buffer.copy`Gravatar Jarred Sumner 12-520/+952
2022-04-30[bun ffi] Fix missing `"void"`Gravatar Jarred Sumner 1-0/+1
2022-04-30[bun ffi] Remove dependency on libtcc1.a and improve error messagesGravatar Jarred Sumner 3-36/+139
2022-04-30wipGravatar Jarred Sumner 9-272/+883
2022-04-30Update ffi-test.cGravatar Jarred Sumner 1-24/+35
2022-04-30aGravatar Jarred Sumner 1-0/+27
2022-04-29[bun:ffi] it worksGravatar Jarred Sumner 15-221/+1277
2022-04-29[bun.js] Implement unsafe.{`arrayBufferToPtr`, `arrayBufferFromPtr`, `bufferF...Gravatar Jarred Sumner 6-82/+187
2022-04-29[bun ffi] Support pointersGravatar Jarred Sumner 4-238/+179
2022-04-29[bun ffi] support `i32`, `i8`, `u8`, `u16`, `i16`, `u32`, `bool`Gravatar Jarred Sumner 5-159/+260
2022-04-29more tests for bufferGravatar Jarred Sumner 1-1/+165
2022-04-29add more to buffer implementationGravatar Jarred Sumner 14-157/+783
2022-04-29ffi test codeGravatar Jarred Sumner 2-26/+247
2022-04-29wipGravatar Jarred Sumner 10-16/+312
2022-04-29commit moreGravatar Jarred Sumner 3-0/+81