Fix #44 Exception when the workspace contains a root folder with another scheme than 'file'

This commit is contained in:
Erich Gamma 2017-10-20 15:44:44 +02:00
Родитель 41635f359a
Коммит 5b67492083
3 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -1,3 +1,4 @@
- 0.3.1 fix for [#44](https://github.com/Microsoft/vscode-npm-scripts/issues/44) Exception when the workspace contains a root folder with another scheme than 'file'
- 0.3.0 support multiple root folders
- 0.2.1 fix for [#32716](https://github.com/Microsoft/vscode/issues/32716) Duplicate setting npm.runSilent
- 0.2.0 fix for [#38](https://github.com/Microsoft/vscode-npm-scripts/issues/38) After closing npm in terminal I can't run command anymore

Просмотреть файл

@ -302,14 +302,11 @@ function registerCommands(context: ExtensionContext) {
);
}
function runNpmCommand(args: string[], cwd?: string, alwaysRunInputWindow = false): void {
function runNpmCommand(args: string[], cwd: string, alwaysRunInputWindow = false): void {
if (runSilent()) {
args.push('--silent');
}
workspace.saveAll().then(() => {
if (!cwd) {
cwd = workspace.rootPath;
}
if (useTerminal() && !alwaysRunInputWindow) {
if (typeof window.createTerminal === 'function') {
@ -342,7 +339,7 @@ function createAllCommand(scriptList: Script[], isScriptCommand: boolean): Scrip
}
function isMultiRoot():boolean {
return workspace.workspaceFolders.length > 1;
return workspace.workspaceFolders && workspace.workspaceFolders.length > 1;
}
function pickScriptToExecute(descriptions: ScriptCommandDescription[], command: string[], allowAll = false, alwaysRunInputWindow = false) {
@ -358,8 +355,8 @@ function pickScriptToExecute(descriptions: ScriptCommandDescription[], command:
label = `${s.relativePath} - ${label}`;
}
if (isMultiRoot()) {
let root = workspace.getWorkspaceFolder(Uri.file(s.absolutePath));
label = `${root.name}: ${label}`
const root = workspace.getWorkspaceFolder(Uri.file(s.absolutePath));
label = `${root.name}: ${label}`;
}
scriptList.push({
label: label,
@ -514,7 +511,7 @@ function commandDescriptionsInPackage(param: string[], packagePath: string, desc
}
}
function commandsDescriptions(command: string[], dirs?: string[]): ScriptCommandDescription[] {
function commandsDescriptions(command: string[], dirs: string[]): ScriptCommandDescription[] {
if (!dirs) {
dirs = getAllIncludedDirectories();
}
@ -794,8 +791,10 @@ function getAllIncludedDirectories(): string[] {
}
for (let i = 0; i < folders.length; i++) {
const dirs = getIncludedDirectories(folders[i].uri);
allDirs.push(...dirs);
if (folders[i].uri.scheme === 'file') {
const dirs = getIncludedDirectories(folders[i].uri);
allDirs.push(...dirs);
}
}
return allDirs;
}

Просмотреть файл

@ -9,6 +9,7 @@
"sourceMap": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"strictNullChecks": false,
"noFallthroughCasesInSwitch": true,
"allowUnreachableCode": false,
"noImplicitAny": true,