mirror of
https://github.com/ayyo42069/HTTPToolkit-Patcher-2026.git
synced 2026-07-15 16:20:02 +02:00
Add support for multiple package manager.
This commit is contained in:
@@ -1 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
bun.lock
|
||||||
|
package-lock.json
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ const argv = await yargs(process.argv.slice(2))
|
|||||||
const isWin = process.platform === 'win32'
|
const isWin = process.platform === 'win32'
|
||||||
const isMac = process.platform === 'darwin'
|
const isMac = process.platform === 'darwin'
|
||||||
|
|
||||||
|
const userAgent = process.env.npm_config_user_agent
|
||||||
|
const pm = userAgent ? userAgent.split('/')[0] : 'npm'
|
||||||
|
const installCmd = pm === 'npm' ? 'install' : 'add'
|
||||||
|
|
||||||
// Try to find where HTTP Toolkit is installed
|
// Try to find where HTTP Toolkit is installed
|
||||||
const appPath =
|
const appPath =
|
||||||
isWin ? path.join(process.env.LOCALAPPDATA ?? '', 'Programs', 'HTTP Toolkit', 'resources')
|
isWin ? path.join(process.env.LOCALAPPDATA ?? '', 'Programs', 'HTTP Toolkit', 'resources')
|
||||||
@@ -180,7 +184,7 @@ const patchApp = async () => {
|
|||||||
console.log(chalk.yellowBright`Installing dependencies...`)
|
console.log(chalk.yellowBright`Installing dependencies...`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const proc = spawn('npm install express https-proxy-agent', { cwd: tempPath, stdio: 'inherit', shell: true })
|
const proc = spawn(`${pm} ${installCmd} express https-proxy-agent`, { cwd: tempPath, stdio: 'inherit', shell: true })
|
||||||
activeProcesses.push(proc)
|
activeProcesses.push(proc)
|
||||||
await new Promise(resolve =>
|
await new Promise(resolve =>
|
||||||
proc.on('close', resolve)
|
proc.on('close', resolve)
|
||||||
@@ -193,6 +197,9 @@ const patchApp = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rm(path.join(tempPath, 'package-lock.json'))
|
rm(path.join(tempPath, 'package-lock.json'))
|
||||||
|
rm(path.join(tempPath, 'yarn.lock'))
|
||||||
|
rm(path.join(tempPath, 'pnpm-lock.yaml'))
|
||||||
|
rm(path.join(tempPath, 'bun.lockb'))
|
||||||
fs.copyFileSync(filePath, `${filePath}.bak`)
|
fs.copyFileSync(filePath, `${filePath}.bak`)
|
||||||
console.log(chalk.greenBright`Created backup at {bold ${filePath}.bak}`)
|
console.log(chalk.greenBright`Created backup at {bold ${filePath}.bak}`)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user