Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review changes
  • Loading branch information
alexr00 committed Oct 9, 2020
commit 49fde806b2f5d6017266f6301883ed98f2d0fdc0
2 changes: 1 addition & 1 deletion extensions/npm/src/scriptHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class NpmScriptHoverProvider implements HoverProvider {
let folder = workspace.getWorkspaceFolder(documentUri);
if (folder) {
let task = await createTask(script, `run ${script}`, folder, documentUri);
tasks.executeTask(task);
await tasks.executeTask(task);
}
}

Expand Down
14 changes: 7 additions & 7 deletions extensions/npm/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function getPackageManager(folder: WorkspaceFolder): Promise<string
packageManagerName = name;

if (multiplePMDetected) {
const multiplePMWarning = localize('npm.multiplePMWarning', 'Found multiple lockfiles. Using {0} as the preferred package manager.', packageManagerName);
const multiplePMWarning = localize('npm.multiplePMWarning', 'Found multiple lockfiles for {0}. Using {1} as the preferred package manager.', folder.uri.fsPath, packageManagerName);
window.showWarningMessage(multiplePMWarning);
}
}
Expand Down Expand Up @@ -291,27 +291,27 @@ export async function createTask(script: NpmTaskDefinition | string, cmd: string
kind = script;
}

async function getCommandLine(folder: WorkspaceFolder, cmd: string): Promise<string> {
let packageManager = await getPackageManager(folder);
const packageManager = await getPackageManager(folder);
async function getCommandLine(cmd: string): Promise<string> {
if (workspace.getConfiguration('npm', folder.uri).get<boolean>('runSilent')) {
return `${packageManager} --silent ${cmd}`;
}
return `${packageManager} ${cmd}`;
}

function getRelativePath(folder: WorkspaceFolder, packageJsonUri: Uri): string {
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(folder, packageJsonUri);
let relativePackageJson = getRelativePath(packageJsonUri);
if (relativePackageJson.length) {
kind.path = getRelativePath(folder, packageJsonUri);
kind.path = relativePackageJson;
}
let taskName = getTaskName(kind.script, relativePackageJson);
let cwd = path.dirname(packageJsonUri.fsPath);
const task = new Task(kind, folder, taskName, 'npm', new ShellExecution(await getCommandLine(folder, cmd), { cwd: cwd }), matcher);
const task = new Task(kind, folder, taskName, 'npm', new ShellExecution(await getCommandLine(cmd), { cwd: cwd }), matcher);
task.detail = detail;
return task;
}
Expand Down