
























@@ -39,6 +39,46 @@ describe("install.sh", () => {
3939expect(script).not.toContain('[[ "$OSTYPE" == "linux-gnu"* ]]');
4040});
414142+it("installs Node.js with apk on Alpine before falling back to NodeSource", () => {
43+expect(script).toContain("finish_linux_node_install()");
44+expect(script).toContain('ui_info "Installing Node.js via apk (Alpine Linux detected)"');
45+expect(script).toContain(
46+'run_quiet_step "Installing Node.js" apk add --no-cache nodejs npm',
47+);
48+expect(script).toContain(
49+'run_quiet_step "Installing Node.js" sudo apk add --no-cache nodejs npm',
50+);
51+expect(script).toContain('if ! node_is_at_least_required; then');
52+53+const apkIndex = script.indexOf('if command -v apk &> /dev/null; then');
54+const nodeSourceIndex = script.indexOf('ui_info "Installing Node.js via NodeSource"');
55+expect(apkIndex).toBeGreaterThan(-1);
56+expect(nodeSourceIndex).toBeGreaterThan(apkIndex);
57+});
58+59+it("uses the apk Node.js installer path on Alpine", () => {
60+const result = runInstallShell(`
61+ set -euo pipefail
62+ source "${SCRIPT_PATH}"
63+ OS=linux
64+ require_sudo() { :; }
65+ install_build_tools_linux() { return 0; }
66+ is_root() { return 0; }
67+ ui_info() { printf 'info:%s\\n' "$*"; }
68+ ui_success() { printf 'success:%s\\n' "$*"; }
69+ run_quiet_step() { printf 'step:%s|%s\\n' "$1" "\${*:2}"; }
70+ apk() { :; }
71+ finish_linux_node_install() { printf 'finish-linux-node\\n'; }
72+ install_node
73+ `);
74+75+expect(result.status).toBe(0);
76+expect(result.stdout).toContain("info:Installing Node.js via apk (Alpine Linux detected)");
77+expect(result.stdout).toContain("step:Installing Node.js|apk add --no-cache nodejs npm");
78+expect(result.stdout).toContain("finish-linux-node");
79+expect(result.stdout).not.toContain("Installing Node.js via NodeSource");
80+});
81+4282it("clears npm freshness filters for package installs", () => {
4383expect(script).toContain("env -u NPM_CONFIG_BEFORE -u npm_config_before");
4484expect(script).toContain('freshness_flag="--min-release-age=0"');
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。