extensions/npm/src/tasks.ts/createTask
export async function createTask(packageManager: string, script: NpmTaskDefinition | string, cmd: string[], folder: WorkspaceFolder, packageJsonUri: Uri, scriptValue?: string, matcher?: any): Promise<Task> {
	let kind: NpmTaskDefinition;
	if (typeof script === 'string') {
		kind = { type: 'npm', script: script };
	} else {
		kind = script;
	}

	function getCommandLine(cmd: string[]): (string | ShellQuotedString)[] {
		const result: (string | ShellQuotedString)[] = new Array(cmd.length);
		for (let i = 0; i < cmd.length; i++) {
			if (/\s/.test(cmd[i])) {
				result[i] = { value: cmd[i], quoting: cmd[i].includes('--') ? ShellQuoting.Weak : ShellQuoting.Strong };
			} else {
				result[i] = cmd[i];
			}
		}
		if (workspace.getConfiguration('npm', folder.uri).get<boolean>('runSilent')) {
			result.unshift('--silent');
		}
		return result;
	}

	function getRelativePath(packageJsonUri: Uri): string {
		let rootUri = folder.uri;
		let absolutePath = packageJsonUri.path.substring(0, packageJsonUri.path.length - 'package.json'.length);
		return absolutePath.substring(rootUri.path.length + 1);
	}

	let relativePackageJson = getRelativePath(packageJsonUri);
	if (relativePackageJson.length) {
		kind.path = relativePackageJson.substring(0, relativePackageJson.length - 1);
	}
	let taskName = getTaskName(kind.script, relativePackageJson);
	let cwd = path.dirname(packageJsonUri.fsPath);
	const task = new Task(kind, folder, taskName, 'npm', new ShellExecution(packageManager, getCommandLine(cmd), { cwd: cwd }), matcher);
	task.detail = scriptValue;

	const lowerCaseTaskName = kind.script.toLowerCase();
	if (isBuildTask(lowerCaseTaskName)) {
		task.group = TaskGroup.Build;
	} else if (isTestTask(lowerCaseTaskName)) {
		task.group = TaskGroup.Test;
	} else if (isPrePostScript(lowerCaseTaskName)) {
		task.group = TaskGroup.Clean; // hack: use Clean group to tag pre/post scripts
	} else if (scriptValue && isDebugScript(scriptValue)) {
		// todo@connor4312: all scripts are now debuggable, what is a 'debug script'?
		task.group = TaskGroup.Rebuild; // hack: use Rebuild group to tag debug scripts
	}
	return task;
}