-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vscode): add support for "workbench.extensions.installExtension"…
… command Signed-off-by: Florian Greinacher <[email protected]>
- Loading branch information
1 parent
5c164f7
commit 62a341b
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/plugin-ext/src/main/node/resolvers/plugin-local-file-resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2018 Red Hat, Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import { PluginDeployerResolver, PluginDeployerResolverContext } from '../../../common/plugin-protocol'; | ||
import { injectable } from 'inversify'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { FileUri } from '@theia/core/lib/node'; | ||
import URI from '@theia/core/lib/common/uri'; | ||
|
||
@injectable() | ||
export class LocalFilePluginDeployerResolver implements PluginDeployerResolver { | ||
|
||
static LOCAL_FILE = 'local-file'; | ||
|
||
/** | ||
* Check all files/folder from the local-dir referenced and add them as plugins. | ||
*/ | ||
async resolve(pluginResolverContext: PluginDeployerResolverContext): Promise<void> { | ||
// get directory | ||
const localFileUri = new URI(pluginResolverContext.getOriginId()); | ||
if (localFileUri.scheme !== LocalFilePluginDeployerResolver.LOCAL_FILE) { | ||
return; | ||
} | ||
// get fs path | ||
let filePath = FileUri.fsPath(localFileUri); | ||
if (!path.isAbsolute(filePath)) { | ||
filePath = path.resolve(process.cwd(), filePath); | ||
} | ||
// check file exists | ||
if (!fs.existsSync(filePath)) { | ||
console.warn(`The file referenced by ${pluginResolverContext.getOriginId()} does not exist.`); | ||
return; | ||
} | ||
const fileName = path.basename(filePath); | ||
pluginResolverContext.addPlugin(fileName, filePath); | ||
} | ||
accept(pluginId: string): boolean { | ||
return pluginId.startsWith(LocalFilePluginDeployerResolver.LOCAL_FILE); | ||
} | ||
} |