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

feat(toFile): the situation where compatible paths cannot exist #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fanxinqi
Copy link

@fanxinqi fanxinqi commented Mar 6, 2024

If the path cannot exist, create the path
If there is a path, follow the original logic normally

If the path cannot exist, create the path
If there is a path, follow the original logic normally
Copy link
Owner

@huan huan left a comment

Choose a reason for hiding this comment

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

Please modify code as requested.

And,

  1. please add a param comment (jsdoc) to the overwrite parameter to explain the new feature.
  2. please add an unit test to test this new feature.

// Check if file exists
let exist = false;
try {
FS.accessSync(fullFilePath);
Copy link
Owner

Choose a reason for hiding this comment

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

use async instead of sync, with await, please

// Create directory if it doesn't exist
const directory = PATH.dirname(fullFilePath);
if (!FS.existsSync(directory)) {
FS.mkdirSync(directory, { recursive: true });
Copy link
Owner

Choose a reason for hiding this comment

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

only do the mkdir if the overwrite is true

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.

None yet

2 participants