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

Ensure sfdx dir exists #716

Merged
merged 1 commit into from
Jun 28, 2023
Merged

Ensure sfdx dir exists #716

merged 1 commit into from
Jun 28, 2023

Conversation

iowillhoit
Copy link
Contributor

What does this PR do?

Prevents forcedotcom/cli#2222 from happening again.
This was unintentionally fixed in forcedotcom/sfdx-core#842

What issues does this PR fix or reference?

@W-13602928@

QA
I reverted back to an older version of the CLI (1.194.1) and then I modified plugin-org directly with the same mkdir code
Screenshot 2023-06-15 at 3 11 21 PM

Confirm existing directory does not cause issues
Screenshot 2023-06-15 at 3 22 06 PM

@@ -129,6 +129,10 @@ export class OrgListUtil {
* @param fileNames All the filenames in the global hidden folder
*/
public static async readAuthFiles(fileNames: string[]): Promise<AuthInfo[]> {
// Ensure that the Global.SFDX_DIR exists
// https://github.com/forcedotcom/cli/issues/2222
await fs.mkdir(Global.SFDX_DIR, { recursive: true });
Copy link
Contributor

@WillieRuemmele WillieRuemmele Jun 16, 2023

Choose a reason for hiding this comment

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

this'll throw if the directory already exists though, do we need to wrap this in try/catch?

just testing this in dreamhouse

 ➜  ls
1686770905635-command-debug.log  CODE_OF_CONDUCT.md               SECURITY.md                      data                             jest.config.js                   tests
1686770905635-command-stdout.log CONTRIBUTION.md                  bin                              dreamhouse-logo.png              package-lock.json
1686770924292-command-debug.log  LICENSE                          codecov.yml                      force-app                        package.json
1686770924292-command-stdout.log README.md                        config                           jest-sa11y-setup.js              sfdx-project.json
➜  dreamhouse-lwc git:(main) ✗  hub:(DevHub) scratch:([email protected])
 ➜  node   
Welcome to Node.js v18.16.0.
Type ".help" for more information.
> fs.mkdirSync('config')
Uncaught Error: EEXIST: file already exists, mkdir 'config'
    at Object.mkdirSync (node:fs:1396:3) {
  errno: -17,
  syscall: 'mkdir',
  code: 'EEXIST',
  path: 'config'
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh! I didn't look closely at what you were testing. The mkdir function will throw if you are not passing { recursive: true } (docs). I just tested this code several more times and it is working as expected.

@WillieRuemmele WillieRuemmele merged commit 3b4ea52 into main Jun 28, 2023
@WillieRuemmele WillieRuemmele deleted the ew/missing-sfdx-dir-error branch June 28, 2023 15:28
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.

2 participants