Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node as npm script runner #236967

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Add node as npm script runner #236967

wants to merge 5 commits into from

Conversation

xymopen
Copy link

@xymopen xymopen commented Dec 26, 2024

Fixes #234468

Copy link
Member

@connor4312 connor4312 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good overall, some comments

const scriptRunner = await getScriptRunner(folder, context, showWarning);
const result = [scriptRunner, scriptRunner === 'node' ? '--run' : 'run'];
if (workspace.getConfiguration('npm', folder).get<boolean>('runSilent')) {
result.push('--silent');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--silent will cause an error if the scriptRunner is node, we should ignore that setting in this case

@@ -104,49 +103,61 @@ function isTestTask(name: string): boolean {
}
return false;
}
const preScripts: Set<string> = new Set([
'est', /* test typo? */ 'install', 'pack', 'pack', 'publish', 'restart',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a typo, you can fix it :)

Comment on lines +124 to +125
export async function getScriptRunner(folder: Uri, context?: ExtensionContext, showWarning?: boolean): Promise<string> {
let scriptRunner = workspace.getConfiguration('npm', folder).get<string>('scriptRunner', 'npm');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default in get here should be auto, and if it's auto then we return getPackageManager(...)

}
}
}
}
return allTasks;
} catch (error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it was added initially, but this catch is a no-op, you can remove the try/catch if you want

const { name, multipleLockFilesDetected: multiplePMDetected } = await findPreferredPM(folder.fsPath);
const neverShowWarning = 'npm.multiplePMWarning.neverShow';
if (showWarning && multiplePMDetected && extensionContext && !extensionContext.globalState.get<boolean>(neverShowWarning)) {
// todo: add text for npm.scriptRunner?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're okay with this text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add node as npm script runner
2 participants