in src/tasks.ts [193:288]
private createTask(
name: string,
folder: vscode.WorkspaceFolder | undefined,
path?: string,
inputPath?: string,
baseline?: string,
modules?: string[],
outcome?: string[],
matcher?: any,
definition?: PSRuleTaskDefinition
): vscode.Task {
if (definition === undefined) {
definition = {
type: PSRuleTaskProvider.taskType,
matcher: '$PSRule',
};
}
function getTaskName() {
return name;
}
function getCmd(): string {
let params = '';
// Path
if (path !== undefined && path !== '') {
params += ` -Path '${path}'`;
} else {
params += " -Path './.ps-rule/'";
}
if (inputPath !== undefined && inputPath !== '') {
params += ` -InputPath '${inputPath}'`;
} else {
params += ` -InputPath .`;
}
// Baseline
if (baseline !== undefined && baseline !== '') {
params += ` -Baseline '${baseline}'`;
}
// Modules
if (modules !== undefined && modules.length > 0) {
for (let i = 0; i < modules.length; i++) {
if (i > 0) {
params += `, ${modules[i]}`;
} else {
params += ` -Module ${modules[i]}`;
}
}
}
// Outcome
if (outcome !== undefined && outcome.length > 0) {
for (let i = 0; i < outcome.length; i++) {
if (i > 0) {
params += `, ${outcome[i]}`;
} else {
params += ` -Outcome ${outcome[i]}`;
}
}
} else {
params += ' -Outcome Fail, Error';
}
return `Assert-PSRule -Format File${params};`;
}
const taskName = getTaskName();
const executionNotProcessedWarning = configuration.get().executionNotProcessedWarning;
const outputAs = configuration.get().outputAs;
// Return the task instance
return new vscode.Task(
definition,
folder ?? vscode.TaskScope.Workspace,
taskName,
PSRuleTaskProvider.taskType,
new vscode.ShellExecution(getCmd(), {
executable: pwsh.path,
shellArgs: ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command'],
env: {
PSRULE_OUTPUT_STYLE: 'VisualStudioCode',
PSRULE_OUTPUT_AS: outputAs.toString(),
PSRULE_OUTPUT_CULTURE: vscode.env.language,
PSRULE_OUTPUT_BANNER: 'Minimal',
PSRULE_EXECUTION_NOTPROCESSEDWARNING: executionNotProcessedWarning
? 'true'
: 'false',
},
}),
matcher
);
}