-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom arguments to provided "func host start" task (#1136)
- Loading branch information
Showing
10 changed files
with
70 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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,45 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { TaskDefinition, workspace, WorkspaceConfiguration, WorkspaceFolder } from 'vscode'; | ||
import { func } from '../constants'; | ||
|
||
interface IFuncTaskDefinition extends TaskDefinition { | ||
command?: string; | ||
} | ||
|
||
/** | ||
* Gets the exact command line (aka with any user-specified args) to be used in our provided task | ||
*/ | ||
export function getFuncTaskCommand(folder: WorkspaceFolder, defaultCommand: string, commandsToMatch: RegExp): IFuncTaskCommand { | ||
let command: string = defaultCommand; | ||
try { | ||
const config: WorkspaceConfiguration = workspace.getConfiguration('tasks', folder.uri); | ||
// tslint:disable-next-line: strict-boolean-expressions | ||
const tasks: IFuncTaskDefinition[] = config.get<IFuncTaskDefinition[]>('tasks') || []; | ||
const funcTask: IFuncTaskDefinition | undefined = tasks.find(t => t.type === func && !!t.command && commandsToMatch.test(t.command)); | ||
if (funcTask && funcTask.command) { | ||
command = funcTask.command; | ||
} | ||
} catch { | ||
// ignore and use default | ||
} | ||
return { | ||
taskName: command, | ||
commandLine: `func ${command}` | ||
}; | ||
} | ||
|
||
export interface IFuncTaskCommand { | ||
/** | ||
* Used to identify the task. It matches the command as defined in the task by the user and is the same as commandLine, except without 'func' at the beginning. | ||
*/ | ||
taskName: string; | ||
|
||
/** | ||
* The actual command line to run | ||
*/ | ||
commandLine: string; | ||
} |