mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-19 16:39:50 +00:00
refactor: replace bun -e with bun eval and require() with ESM imports in shell scripts (#2505)
Per shell-scripts.md rules: always use `bun eval` (not `bun -e`) and ESM-only
(never `require()`). Fixed in:
- sh/shared/key-request.sh: 3 instances of `bun -e` → `bun eval`
- sh/e2e/lib/soak.sh: `bun -e` → `bun eval`; `require("fs")`/`require("path")` →
named ESM imports from node:fs and node:path
Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
This commit is contained in:
parent
65a2efd5ba
commit
1d2bf324c4
2 changed files with 10 additions and 9 deletions
|
|
@ -97,20 +97,21 @@ soak_inject_telegram_config() {
|
|||
|
||||
log_step "Patching ~/.openclaw/openclaw.json with Telegram bot token..."
|
||||
|
||||
# Use bun -e on the remote to JSON-patch the config file
|
||||
# Use bun eval on the remote to JSON-patch the config file
|
||||
cloud_exec "${app}" "source ~/.spawnrc 2>/dev/null; \
|
||||
export PATH=\$HOME/.npm-global/bin:\$HOME/.bun/bin:\$HOME/.local/bin:\$PATH; \
|
||||
_TOKEN=\$(printf '%s' '${encoded_token}' | base64 -d); \
|
||||
bun -e ' \
|
||||
const fs = require(\"fs\"); \
|
||||
bun eval ' \
|
||||
import { mkdirSync, readFileSync, writeFileSync } from \"node:fs\"; \
|
||||
import { dirname } from \"node:path\"; \
|
||||
const configPath = process.env.HOME + \"/.openclaw/openclaw.json\"; \
|
||||
let config = {}; \
|
||||
try { config = JSON.parse(fs.readFileSync(configPath, \"utf-8\")); } catch {} \
|
||||
try { config = JSON.parse(readFileSync(configPath, \"utf-8\")); } catch {} \
|
||||
if (!config.channels) config.channels = {}; \
|
||||
if (!config.channels.telegram) config.channels.telegram = {}; \
|
||||
config.channels.telegram.botToken = process.env._TOKEN; \
|
||||
fs.mkdirSync(require(\"path\").dirname(configPath), { recursive: true }); \
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); \
|
||||
mkdirSync(dirname(configPath), { recursive: true }); \
|
||||
writeFileSync(configPath, JSON.stringify(config, null, 2)); \
|
||||
console.log(\"Telegram config injected\"); \
|
||||
'" >/dev/null 2>&1
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ _parse_cloud_auths() {
|
|||
if command -v jq &>/dev/null; then
|
||||
jq -r '.clouds | to_entries[] | select(.value.auth != null and .value.auth != "") | select(.value.key_request != false) | select(.value.auth | test("\\b(login|configure|setup)\\b"; "i") | not) | "\(.key)|\(.value.auth)"' "${manifest_path}" 2>/dev/null
|
||||
else
|
||||
_MANIFEST="${manifest_path}" bun -e "
|
||||
_MANIFEST="${manifest_path}" bun eval "
|
||||
import fs from 'fs';
|
||||
const m = JSON.parse(fs.readFileSync(process.env._MANIFEST, 'utf8'));
|
||||
for (const [key, cloud] of Object.entries(m.clouds || {})) {
|
||||
|
|
@ -63,7 +63,7 @@ _try_load_env_var() {
|
|||
if command -v jq &>/dev/null; then
|
||||
val=$(jq -r --arg v "${var_name}" '(.[$v] // .api_key // .token) // "" | select(. != null)' "${config_file}" 2>/dev/null)
|
||||
else
|
||||
val=$(_FILE="${config_file}" _VAR="${var_name}" bun -e "
|
||||
val=$(_FILE="${config_file}" _VAR="${var_name}" bun eval "
|
||||
import fs from 'fs';
|
||||
const d = JSON.parse(fs.readFileSync(process.env._FILE, 'utf8'));
|
||||
process.stdout.write(d[process.env._VAR] || d.api_key || d.token || '');
|
||||
|
|
@ -194,7 +194,7 @@ request_missing_cloud_keys() {
|
|||
if command -v jq &>/dev/null; then
|
||||
providers_json=$(printf '%s\n' ${MISSING_KEY_PROVIDERS} | jq -Rn '[inputs | select(. != "")]' 2>/dev/null) || return 0
|
||||
elif command -v bun &>/dev/null; then
|
||||
providers_json=$(_PROVIDERS="${MISSING_KEY_PROVIDERS}" bun -e "
|
||||
providers_json=$(_PROVIDERS="${MISSING_KEY_PROVIDERS}" bun eval "
|
||||
const providers = process.env._PROVIDERS.trim().split(/\s+/).filter(Boolean);
|
||||
process.stdout.write(JSON.stringify(providers));
|
||||
" 2>/dev/null) || return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue