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

Continue fs-extra migration #1

Conversation

raphinesse
Copy link

@raphinesse raphinesse commented May 29, 2018

I left the commits small so changes can be more easily tracked. Feel free to squash after changes have been reviewed. You can add me as a Co-Author.

});
afterEach(function () {
afterAll(function () {
Copy link
Owner

Choose a reason for hiding this comment

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

Why this change and why here?

Copy link
Author

@raphinesse raphinesse May 29, 2018

Choose a reason for hiding this comment

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

Why: Since with emptyDirSync we empty tmpDir in beforeEach so there's no need to delete the tmpDir itself after every test, only at the very end.

Why here: Because this change is kind of enabled by the rich fs-extra API 🤷‍♂️

Copy link
Owner

@brody4hire brody4hire left a comment

Choose a reason for hiding this comment

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

I got a few more questions, looks great in general, I will try running spec on your changes next.

index.js Outdated
@@ -309,7 +309,7 @@ function copyTemplateFiles (templateDir, projectDir, isSubDir) {
// if template is a www dir
if (path.basename(templateDir) === 'www') {
copyPath = path.resolve(templateDir);
fs.copySync(copyPath, projectDir);
fs.copySync(copyPath, path.resolve(projectDir, 'www'));
Copy link
Owner

Choose a reason for hiding this comment

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

I am wondering why this problem does not show up when I run the spec?

Copy link
Author

@raphinesse raphinesse May 29, 2018

Choose a reason for hiding this comment

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

I didn't check, but this case might not be covered or not sufficiently tested. Or I'm just plainly wrong 😉

But as far as I understand it, with copySync you always have the full file path in either argument. Whether you copy file or folder. This leads to less surprising if a bit wordier copying IMO.

index.js Outdated
@@ -400,7 +400,7 @@ function linkFromTemplate (templateDir, projectDir) {
// if template/www/config.xml then copy to project/config.xml
copyDst = path.join(projectDir, 'config.xml');
if (!fs.existsSync(copyDst) && fs.existsSync(copySrc)) {
fs.copySync(copySrc, projectDir);
Copy link
Owner

Choose a reason for hiding this comment

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

Ditto: I am wondering why this problem does not show up when I run the spec?

index.js Outdated
copyContentsIfNotExists(stockAssetPath('www'), path.join(dir, 'www'));
copyContentsIfNotExists(stockAssetPath('hooks'), path.join(dir, 'hooks'));
copyIfNotExists(stockAssetPath('www'), path.join(dir, 'www'));
copyIfNotExists(stockAssetPath('hooks'), path.join(dir, 'hooks'));
Copy link
Owner

Choose a reason for hiding this comment

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

I wanted to make it more clear about what this function actually does? Wonder if we should just remove the separate function altogether?

Copy link
Author

Choose a reason for hiding this comment

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

Well, the function would also work for plain files. But for that case the name makes no sense.

I'd keep it for now. It will have to be changed anyway in case some of apache/cordova-discuss#89 is accepted.

@brody4hire brody4hire force-pushed the introduce-fs-extra-usage branch 2 times, most recently from f89950f to 538a345 Compare May 30, 2018 00:40
@raphinesse raphinesse closed this May 30, 2018
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