From ccaa5d84c5718ce66e887b7bed620366fc859c11 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Mon, 22 Jul 2019 09:21:21 +0000 Subject: [PATCH] [vscode] fix #5756: unzip node_modules for built-in extensions Signed-off-by: Anton Kosyakov --- CHANGELOG.md | 1 + .../src/node/plugin-vscode-file-handler.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2735fe794e4..72580c124d496 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [security] Bump lodash.mergewith from 4.6.1 to 4.6.2 - [plugin] Fixed `Converting circular structure to JSON` Error [#5661](https://github.com/theia-ide/theia/pull/5661) - [plugin] fixed auto detection of new languages [#5753](https://github.com/theia-ide/theia/issues/5753) +- [vscode] unzip node_modules for built-in extensions [#5756](https://github.com/theia-ide/theia/pull/5756) Breaking changes: diff --git a/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts b/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts index f6fdc27df0411..7e3476c14546a 100644 --- a/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts +++ b/packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts @@ -16,6 +16,7 @@ import { PluginDeployerFileHandler, PluginDeployerEntry, PluginDeployerFileHandlerContext } from '@theia/plugin-ext'; import { injectable } from 'inversify'; +import * as fs from 'fs-extra'; import * as path from 'path'; import { getTempDir } from '@theia/plugin-ext'; @@ -41,6 +42,13 @@ export class PluginVsCodeFileHandler implements PluginDeployerFileHandler { const unpackedPath = path.resolve(this.unpackedFolder, path.basename(context.pluginEntry().path())); await context.unzip(context.pluginEntry().path(), unpackedPath); + if (context.pluginEntry().path().endsWith('.tgz')) { + const extensionPath = path.join(unpackedPath, 'package'); + const vscodeNodeModulesPath = path.join(extensionPath, 'vscode_node_modules.zip'); + if (await fs.pathExists(vscodeNodeModulesPath)) { + await context.unzip(vscodeNodeModulesPath, path.join(extensionPath, 'node_modules')); + } + } context.pluginEntry().updatePath(unpackedPath); return Promise.resolve();