#!/usr/bin/env shset -eu# Copied from ../lib.sh except we do not rename Darwin and we do not need to# detect Alpine.os() {osname=$(uname | tr '[:upper:]' '[:lower:]')case $osname incygwin* | mingw*) osname="windows" ;;esacecho "$osname"}# Create a symlink at 2ドル pointing to 1ドル on any platform. Anything that# currently exists at 2ドル will be deleted.symlink() {source="1ドル"dest="2ドル"rm -rf "$dest"case $OS inwindows) mklink /J "$dest" "$source" ;;*) ln -s "$source" "$dest" ;;esac}# VS Code bundles some modules into an asar which is an archive format that# works like tar. It then seems to get unpacked into node_modules.asar.## I don't know why they do this but all the dependencies they bundle already# exist in node_modules so just symlink it. We have to do this since not only# Code itself but also extensions will look specifically in this directory for# files (like the ripgrep binary or the oniguruma wasm).symlink_asar() {symlink node_modules node_modules.asar}# Make a symlink at bin/1ドル/3ドル pointing to the platform-specific version of the# script in 2ドル. The extension of the link will be .cmd for Windows otherwise it# will be whatever is in 4ドル (or no extension if 4ドル is not set).symlink_bin_script() {oldpwd="$(pwd)"cd "bin/1ドル"source="2ドル"dest="3ドル"ext="${4-}"case $OS inwindows) symlink "$source.cmd" "$dest.cmd" ;;darwin | macos) symlink "$source-darwin.sh" "$dest$ext" ;;*) symlink "$source-linux.sh" "$dest$ext" ;;esaccd "$oldpwd"}command_exists() {if [ ! "1ドル" ]; then return 1; ficommand -v "$@" > /dev/null}is_root() {if command_exists id && [ "$(id -u)" = 0 ]; thenreturn 0fireturn 1}OS="$(os)"main() {# Grabs the major version of node from $npm_config_user_agent which looks like# yarn/1.21.1 npm/? node/v14.2.0 darwin x64major_node_version=$(echo "$npm_config_user_agent" | sed -n 's/.*node\/v\([^.]*\).*/1円/p')if [ -n "${FORCE_NODE_VERSION:-}" ]; thenecho "WARNING: Overriding required Node.js version to v$FORCE_NODE_VERSION"echo "This could lead to broken functionality, and is unsupported."echo "USE AT YOUR OWN RISK!"fiif [ "$major_node_version" -ne "${FORCE_NODE_VERSION:-20}" ]; thenecho "ERROR: code-server currently requires node v20."if [ -n "$FORCE_NODE_VERSION" ]; thenecho "However, you have overrided the version check to use v$FORCE_NODE_VERSION."fiecho "We have detected that you are on node v$major_node_version"echo "You can override this version check by setting \$FORCE_NODE_VERSION,"echo "but configurations that do not use the same node version are unsupported."exit 1fi# Under npm, if we are running as root, we need --unsafe-perm otherwise# post-install scripts will not have sufficient permissions to do their thing.if is_root; thencase "${npm_config_user_agent-}" in npm*)if [ "${npm_config_unsafe_perm-}" != "true" ]; thenecho "Please pass --unsafe-perm to npm to install code-server"echo "Otherwise post-install scripts will not have permissions to run"echo "See https://docs.npmjs.com/misc/config#unsafe-perm"echo "See https://stackoverflow.com/questions/49084929/npm-sudo-global-installation-unsafe-perm"exit 1fi;;esacfiif ! vscode_install; thenecho "You may not have the required dependencies to build the native modules."echo "Please see https://github.com/coder/code-server/blob/main/docs/npm.md"exit 1fiif [ -n "${FORCE_NODE_VERSION:-}" ]; thenecho "WARNING: The required Node.js version was overriden to v$FORCE_NODE_VERSION"echo "This could lead to broken functionality, and is unsupported."echo "USE AT YOUR OWN RISK!"fi}install_with_yarn_or_npm() {echo "User agent: ${npm_config_user_agent-none}"# For development we enforce npm, but for installing the package as an# end-user we want to keep using whatever package manager is in use.case "${npm_config_user_agent-}" innpm*)if ! npm install --unsafe-perm --omit=dev; thenreturn 1fi;;yarn*)if ! yarn --production --frozen-lockfile --no-default-rc; thenreturn 1fi;;*)echo "Could not determine which package manager is being used to install code-server"exit 1;;esacreturn 0}vscode_install() {echo 'Installing Code dependencies...'cd lib/vscodeif ! install_with_yarn_or_npm; thenreturn 1fisymlink_asarsymlink_bin_script remote-cli code code-serversymlink_bin_script helpers browser browser .shcd extensionsif ! install_with_yarn_or_npm; thenreturn 1fireturn 0}main "$@"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。