/** * Preinstall script: rewrites the generalFunctions dependency * from git+https to a local file path when the submodule exists. * This avoids needing Gitea credentials during npm install. */ const fs = require('fs'); const path = require('path'); const pkgPath = path.join(__dirname, '..', 'package.json'); const localGF = path.join(__dirname, '..', 'nodes', 'generalFunctions'); if (fs.existsSync(localGF) && fs.existsSync(path.join(localGF, 'index.js'))) { const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); if (pkg.dependencies && pkg.dependencies.generalFunctions && pkg.dependencies.generalFunctions.startsWith('git+')) { pkg.dependencies.generalFunctions = 'file:./nodes/generalFunctions'; fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); console.log('[patch-deps] Rewrote generalFunctions to local path'); } }