Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/shared-pnpm-store/install.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/bin/sh
#!/usr/bin/env bash

set -e
set -euo pipefail

USERNAME=${USERNAME:-${_REMOTE_USER}}
USERNAME=${USERNAME:-${_REMOTE_USER:-}}
FEATURE_ID="shared-pnpm-store"
STORE_DIR="/mnt/shared-pnpm-store"
LIFECYCLE_SCRIPTS_DIR="/usr/local/share/${FEATURE_ID}/scripts"

echo "Ensuring pnpm store directory ${STORE_DIR} exists..."
mkdir -p "${STORE_DIR}"

if [ -n "${USERNAME}" ] && [ "${USERNAME}" != "root" ]; then
if [[ -n "${USERNAME}" && "${USERNAME}" != "root" ]]; then
echo "Setting owner of ${STORE_DIR} to ${USERNAME}..."
chown -R "${USERNAME}:${USERNAME}" "${STORE_DIR}"
else
echo "No non-root user; leaving ${STORE_DIR} owned by root."
fi

# Install lifecycle script (re-asserts ownership at container create time)
if [ -f oncreate.sh ]; then
if [[ -f oncreate.sh ]]; then
echo "Installing oncreate.sh to ${LIFECYCLE_SCRIPTS_DIR}..."
mkdir -p "${LIFECYCLE_SCRIPTS_DIR}"
cp oncreate.sh "${LIFECYCLE_SCRIPTS_DIR}/oncreate.sh"
Expand Down
6 changes: 3 additions & 3 deletions src/shared-pnpm-store/oncreate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#!/usr/bin/env bash

set -e
set -euo pipefail

STORE_DIR="/mnt/shared-pnpm-store"

Expand All @@ -9,7 +9,7 @@ STORE_DIR="/mnt/shared-pnpm-store"
# ownership for the current non-root user on every container create so pnpm can
# always write to the store, even if the volume was first created by root or a
# different user.
if [ "$(id -u)" != "0" ]; then
if [[ "$(id -u)" != "0" ]]; then
USERNAME="$(id -un)"
echo "Setting owner of ${STORE_DIR} to ${USERNAME}..."
sudo chown -R "${USERNAME}:${USERNAME}" "${STORE_DIR}"
Expand Down
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/_default.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

# Default assertions, reused by scenarios that have pnpm installed.
# Not run directly as a scenario.
Expand Down
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/fish_shell.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

# fish feature installed alongside
./_default.sh
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/node_v2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

# node feature v2 installs latest pnpm by default; this feature touches no
# pnpm global state, so the default assertions are sufficient.
Expand Down
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/pnpm_from_feature.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

# pnpm installed via the node feature
./_default.sh
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/root_user.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

source dev-container-features-test-lib

Expand Down
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

# Optional: Import test library
source dev-container-features-test-lib
Expand Down
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/with_node.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

# pnpm already present in the base image
./_default.sh
2 changes: 1 addition & 1 deletion test/shared-pnpm-store/zsh_shell.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -euo pipefail

# zsh configured as default shell
./_default.sh
Loading