mirror of
https://github.com/Eugeny/tabby.git
synced 2025-08-16 14:21:53 +00:00
.github
.vscode
app
assets
lib
app.ts
cli.ts
config.ts
index.ts
lru.ts
pluginManager.ts
portable.ts
pty.ts
sentry.ts
stringDecoder.ts
utfSplitter.ts
window.ts
src
dev-app-update.yml
index.pug
package.json
tsconfig.json
tsconfig.main.json
webpack.config.js
webpack.main.config.js
yarn.lock
build
docs
extras
patches
scripts
snap
tabby-community-color-schemes
tabby-core
tabby-electron
tabby-linkifier
tabby-local
tabby-plugin-manager
tabby-serial
tabby-settings
tabby-ssh
tabby-telnet
tabby-terminal
tabby-uac
tabby-web
tabby-web-demo
web
.all-contributorsrc
.eslintrc.yml
.gitignore
.mergify.yml
.pug-lintrc.js
CODE_OF_CONDUCT.md
HACKING.md
LICENSE
README.ko-KR.md
README.md
appveyor.yml
electron-builder.yml
firebase.json
package.json
tsconfig.json
typedoc.js
webpack.config.js
webpack.plugin.config.js
yarn.lock
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { promisify } from 'util'
|
|
|
|
|
|
export class PluginManager {
|
|
npm: any
|
|
npmReady?: Promise<void>
|
|
|
|
async ensureLoaded (): Promise<void> {
|
|
if (!this.npmReady) {
|
|
this.npmReady = new Promise(resolve => {
|
|
const npm = require('npm')
|
|
npm.load(err => {
|
|
if (err) {
|
|
console.error(err)
|
|
return
|
|
}
|
|
npm.config.set('global', false)
|
|
this.npm = npm
|
|
resolve()
|
|
})
|
|
})
|
|
}
|
|
return this.npmReady
|
|
}
|
|
|
|
async install (path: string, name: string, version: string): Promise<void> {
|
|
await this.ensureLoaded()
|
|
this.npm.prefix = path
|
|
return promisify(this.npm.commands.install)([`${name}@${version}`])
|
|
}
|
|
|
|
async uninstall (path: string, name: string): Promise<void> {
|
|
await this.ensureLoaded()
|
|
this.npm.prefix = path
|
|
return promisify(this.npm.commands.remove)([name])
|
|
}
|
|
}
|
|
|
|
|
|
export const pluginManager = new PluginManager()
|