Skip to content

Commit

Permalink
Merge pull request #39 from TylerLeonhardt/bundle-pses
Browse files Browse the repository at this point in the history
Move to bundle PowerShellEditorServices
  • Loading branch information
Yatao Li authored Jul 6, 2019
2 parents 245a21b + ca962ee commit d1ccd2f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 108 deletions.
4 changes: 4 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ param(
$Watch
)

if (!(Test-Path "$PSScriptRoot/PowerShellEditorServices")) {
& "$PSScriptRoot/downloadPSES.ps1"
}

if (!(Get-Command npm)) {
throw "You must install Node.js & npm."
}
Expand Down
2 changes: 1 addition & 1 deletion src/downloadPSES.ps1 → downloadPSES.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $ErrorActionPreference = "Stop"
# Progress doesn't display properly in vim
$ProgressPreference = "SilentlyContinue"

Push-Location (Join-Path $PSScriptRoot ..)
Push-Location $PSScriptRoot

$repo = "PowerShell/PowerShellEditorServices"
$file = "PowerShellEditorServices.zip"
Expand Down
82 changes: 1 addition & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"syntaxes",
"src/downloadPSES.ps1",
"README.md",
"LICENSE"
"LICENSE",
"PowerShellEditorServices"
],
"contributes": {
"languages": [
Expand Down Expand Up @@ -292,12 +293,9 @@
"watch": "tsc -watch -p ./"
},
"extensionDependencies": [],
"dependencies": {
"node-powershell": "^4.0.0"
},
"dependencies": {},
"devDependencies": {
"@types/node": "^10.3.3",
"@types/node-powershell": "^3.1.0",
"typescript": "^3.0.3",
"coc.nvim": "^0.0.71"
}
Expand Down
24 changes: 3 additions & 21 deletions src/client/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import cp = require("child_process");
import fs = require("fs");
import net = require("net");
import os = require("os");
import path = require("path");
import vscode = require("coc.nvim");
import Settings = require("./settings");
import utils = require("./utils");
import crypto = require("crypto");
import Shell from "node-powershell";

export class PowerShellProcess {
public static escapeSingleQuotes(pspath: string): string {
Expand Down Expand Up @@ -43,23 +39,9 @@ export class PowerShellProcess {

// If PowerShellEditorServices is not downloaded yet, run the install script to do so.
if (!fs.existsSync(this.bundledModulesPath)) {
let notification = vscode.workspace.createStatusBarItem(0, { progress: true})
notification.text = "Downloading PowerShellEditorServices..."
notification.show()

const ps = new Shell({
executionPolicy: 'Bypass',
noProfile: true
});

ps.addCommand(path.join(this.cocPowerShellRoot, "src", "downloadPSES.ps1"));
await ps.invoke()
.catch(e => logger.appendLine("error downloading PSES: " + e))
.finally(() => {
notification.hide()
notification.dispose()
});

const errMessage = "[Error] PowerShell Editor Services not found. Package is not in the correct format."
this.log.appendLine(errMessage);
throw errMessage;
}

this.log.appendLine("starting.")
Expand Down

0 comments on commit d1ccd2f

Please sign in to comment.