diff --git a/lib/shadow/pnpm-cli.cjs b/lib/shadow/pnpm-cli.cjs index 0ea8b300..e92ad284 100644 --- a/lib/shadow/pnpm-cli.cjs +++ b/lib/shadow/pnpm-cli.cjs @@ -3,6 +3,7 @@ 'use strict' const { spawn } = require('child_process') const { realpathSync } = require('fs') +const fs = require('fs') const path = require('path') const realFilename = realpathSync(__filename) @@ -14,9 +15,24 @@ async function main () { const pnpmpath = await require('./link.cjs')(path.join(realDirname, 'bin'), 'pnpm') process.exitCode = 1 const injectionpath = path.join(realDirname, 'pnpm-injection.cjs') - console.log(process.execPath) + const pnpmModulePath = `${process.env.PNPM_HOME}/global/5/.pnpm/pnpm@9.1.0/node_modules/pnpm/dist/pnpm.cjs` + + // require.cache[process.argv[1]] = { exports: {} } + // require.cache[pnpmModulePath] = { get exports() {console.log(123)} } + // require('module').Module.runMain = () => {} + + // Read module file + // await fs.readFile(pnpmModulePath, 'utf-8' , (err, data) => { + // if (err) throw err; + // console.log(data); + // }); + + // Require the installed pnpm module + require(pnpmModulePath) // spawn(process.execPath, ['--require', injectionpath, pnpmpath, ...process.argv.slice(2)], { + // spawn(process.execPath, ['--require', injectionpath, pnpmModulePath, ...process.argv.slice(2)], { + // spawn(process.execPath, ['--require', pnpmModulePath, ...process.argv.slice(2)], { // stdio: 'inherit' // }).on('exit', (code, signal) => { // if (signal) { diff --git a/lib/shadow/pnpm-injection.cjs b/lib/shadow/pnpm-injection.cjs index 85d3862c..a14dde2e 100644 --- a/lib/shadow/pnpm-injection.cjs +++ b/lib/shadow/pnpm-injection.cjs @@ -2,19 +2,30 @@ // THIS MUST BE CJS TO WORK WITH --require 'use strict' -const path = require('path') +// const path = require('path') -try { - // due to update-notifier pkg being ESM only we actually spawn a subprocess sadly - require('child_process').spawnSync(process.execPath, [ - path.join(__dirname, 'update-notifier.mjs') - ], { - stdio: 'inherit' - }) -} catch (e) { - // ignore if update notification fails +// try { +// // due to update-notifier pkg being ESM only we actually spawn a subprocess sadly +// // require('child_process').spawnSync(process.execPath, [ +// // path.join(__dirname, 'update-notifier.mjs') +// // ], { +// // stdio: 'inherit' +// // }) +// } catch (e) { +// // ignore if update notification fails +// } + +// require.cache[process.argv[1]] = { exports: {} } + +const pnpmInjection = async (depGraph) => { + if (process.env.SOCKET_PNPM_WRAPPER) { + + } } -// console.log('HERE: ', process.argv[1]) +const dryRun = Boolean(process.env.SOCKET_PNPM_WRAPPER) -require.cache[process.argv[1]] = { exports: {} } \ No newline at end of file +module.exports = { + pnpmInjection, + dryRun +} \ No newline at end of file