go_js_wasm_exec 801 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  3. # SPDX-FileCopyrightText: 2019 Alex Browne
  4. # SPDX-License-Identifier: MIT
  5. # Check Node.js version
  6. if [[ $(node --version) =~ v[0-9]\. ]]
  7. then
  8. echo "Node.js version >= 10 is required"
  9. exit 1
  10. fi
  11. SOURCE="${BASH_SOURCE[0]}"
  12. while [ -h "$SOURCE" ]; do
  13. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  14. SOURCE="$(readlink "$SOURCE")"
  15. [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
  16. done
  17. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  18. NODE_WASM_EXEC="$(go env GOROOT)/misc/wasm/wasm_exec_node.js"
  19. WASM_EXEC="$(go env GOROOT)/misc/wasm/wasm_exec.js"
  20. if test -f "$NODE_WASM_EXEC"; then
  21. exec node --require="${DIR}/node_shim.js" "$NODE_WASM_EXEC" "$@"
  22. else
  23. exec node --require="${DIR}/node_shim.js" "$WASM_EXEC" "$@"
  24. fi