node-version-use
Version:
Cross-platform solution for using multiple versions of node. Useful for compatibility testing
1 lines • 2.66 kB
Source Map (JSON)
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/assets/postinstall.cts"],"sourcesContent":["/**\n * Postinstall script for node-version-use\n *\n * Downloads the platform-specific binary and installs it to ~/.nvu/bin/\n * This enables transparent Node version switching.\n *\n * Uses safe atomic download pattern:\n * 1. Download to temp file\n * 2. Extract to temp directory\n * 3. Atomic rename to final location\n */\n\nconst exit = require('exit-compat');\nconst path = require('path');\nconst os = require('os');\nconst { installBinaries, printInstructions, syncAllShims } = require('./installBinaries.cjs');\n\nconst hasHomedir = typeof os.homedir === 'function';\nfunction homedir(): string {\n if (hasHomedir) return os.homedir();\n const home = require('homedir-polyfill');\n return home();\n}\n\n// Allow NVU_HOME override for testing\nconst storagePath = process.env.NVU_HOME || path.join(homedir(), '.nvu');\n\n/**\n * Main installation function\n */\nfunction main(): void {\n installBinaries({}, (err: Error | null, installed: boolean) => {\n if (err) {\n console.log(`postinstall warning: Failed to install binary: ${err.message || err}`);\n console.log('You can still use nvu with explicit versions: nvu 18 npm test');\n return exit(1);\n }\n\n if (installed) {\n // Sync all shims to the new binary version\n const binDir = path.join(storagePath, 'bin');\n syncAllShims(binDir);\n\n printInstructions();\n console.log('postinstall: Binary installed successfully!');\n } else {\n console.log('postinstall: Binaries already up to date.');\n }\n exit(0);\n });\n}\n\nmain();\n"],"names":["exit","require","path","os","installBinaries","printInstructions","syncAllShims","hasHomedir","homedir","home","storagePath","process","env","NVU_HOME","join","main","err","installed","console","log","message","binDir"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,OAAOD,QAAQ;AACrB,MAAME,KAAKF,QAAQ;AACnB,MAAM,EAAEG,eAAe,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGL,QAAQ;AAErE,MAAMM,aAAa,OAAOJ,GAAGK,OAAO,KAAK;AACzC,SAASA;IACP,IAAID,YAAY,OAAOJ,GAAGK,OAAO;IACjC,MAAMC,OAAOR,QAAQ;IACrB,OAAOQ;AACT;AAEA,sCAAsC;AACtC,MAAMC,cAAcC,QAAQC,GAAG,CAACC,QAAQ,IAAIX,KAAKY,IAAI,CAACN,WAAW;AAEjE;;CAEC,GACD,SAASO;IACPX,gBAAgB,CAAC,GAAG,CAACY,KAAmBC;QACtC,IAAID,KAAK;YACPE,QAAQC,GAAG,CAAC,CAAC,+CAA+C,EAAEH,IAAII,OAAO,IAAIJ,KAAK;YAClFE,QAAQC,GAAG,CAAC;YACZ,OAAOnB,KAAK;QACd;QAEA,IAAIiB,WAAW;YACb,2CAA2C;YAC3C,MAAMI,SAASnB,KAAKY,IAAI,CAACJ,aAAa;YACtCJ,aAAae;YAEbhB;YACAa,QAAQC,GAAG,CAAC;QACd,OAAO;YACLD,QAAQC,GAAG,CAAC;QACd;QACAnB,KAAK;IACP;AACF;AAEAe"}