fix: install cosknow globally to always fetch latest version
This commit is contained in:
parent
997b83a313
commit
9456adc087
|
|
@ -62,7 +62,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@agentclientprotocol/sdk": "^0.19.0",
|
"@agentclientprotocol/sdk": "^0.19.0",
|
||||||
"@claude-code-best/mcp-chrome-bridge": "^2.0.8",
|
"@claude-code-best/mcp-chrome-bridge": "^2.0.8",
|
||||||
"cosknow": "latest",
|
|
||||||
"ws": "^8.20.0"
|
"ws": "^8.20.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,25 @@
|
||||||
|
import { spawnSync, execSync } from 'node:child_process'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
import { pathToFileURL } from 'node:url'
|
||||||
|
|
||||||
|
// 全局安装最新版
|
||||||
|
spawnSync('npm', ['install', '-g', '@costrict/cosknow@latest'], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
shell: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取全局 node_modules 路径
|
||||||
|
let globalPrefix
|
||||||
|
try {
|
||||||
|
globalPrefix = execSync('npm root -g', { encoding: 'utf8' }).trim()
|
||||||
|
} catch {
|
||||||
|
console.warn('[cosknow] cannot determine global npm root, skipping')
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
let install
|
let install
|
||||||
try {
|
try {
|
||||||
const mod = await import('cosknow')
|
const mod = await import(pathToFileURL(join(globalPrefix, '@costrict', 'cosknow', 'dist', 'index.js')).href)
|
||||||
install = mod.install
|
install = mod.install
|
||||||
} catch {
|
} catch {
|
||||||
console.warn('[cosknow] package not available, skipping command installation')
|
console.warn('[cosknow] package not available, skipping command installation')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user