-
Notifications
You must be signed in to change notification settings - Fork 30k
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
base: main
Are you sure you want to change the base?
Add node as npm script runner #236967
Conversation
c5cd0cc
to
c1aadd8
Compare
There was a problem hiding this 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'); |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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 :)
export async function getScriptRunner(folder: Uri, context?: ExtensionContext, showWarning?: boolean): Promise<string> { | ||
let scriptRunner = workspace.getConfiguration('npm', folder).get<string>('scriptRunner', 'npm'); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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
Fixes #234468