-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added option to enable corepack #901
base: main
Are you sure you want to change the base?
Changes from 1 commit
2936fe8
7c0fdd0
f9532b2
28c91a3
d8a8b93
802542b
c871b9d
c73bf90
0c618ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import * as exec from '@actions/exec'; | |
|
||
import fs from 'fs'; | ||
import path from 'path'; | ||
import {getCommandOutput} from './cache-utils'; | ||
|
||
export function getNodeVersionFromFile(versionFilePath: string): string | null { | ||
if (!fs.existsSync(versionFilePath)) { | ||
|
@@ -107,14 +108,12 @@ export const unique = () => { | |
}; | ||
|
||
export async function enableCorepack(input: string): Promise<void> { | ||
const corepackArgs = ['enable']; | ||
if (input.length > 0 && input !== 'false') { | ||
if (input.length && input !== 'false') { | ||
const corepackArgs = ['enable']; | ||
if (input !== 'true') { | ||
const packageManagers = input.split(' '); | ||
corepackArgs.push(...packageManagers); | ||
} | ||
await exec.getExecOutput('corepack', corepackArgs, { | ||
ignoreReturnCode: true | ||
}); | ||
await getCommandOutput(`corepack ${corepackArgs.join(' ')}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking back at previous PRs, it was suggested that if Yarn ends up being enabled, any existing Yarn installation (which is evidently present on GitHub runners) should be uninstalled first: #482 (review). Is this is a concern? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought corepack would interop with existing yarn installations (could be wrong) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the existing Yarn installation can be left as is and it won't cause conflict with the installed Yarn from Corepack. |
||
} | ||
} |
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.
Maybe also trim the input and split by
\s+
to avoid issues due to leading, trailing and double-spacing, and also supporting multiline