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

fix: compatible with Node.js 14 #60

Merged
merged 2 commits into from Apr 25, 2020
Merged

fix: compatible with Node.js 14 #60

merged 2 commits into from Apr 25, 2020

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Apr 24, 2020

This PR makes some fixes to make hexo-fs compatible with Node.js 14.

Related issue: hexojs/hexo#4260 hexojs/hexo#4263

@coveralls
Copy link

coveralls commented Apr 24, 2020

Coverage Status

Coverage increased (+0.2%) to 96.491% when pulling 4a4d07a on SukkaW:node-14 into 4508c6e on hexojs:master.

@@ -190,7 +193,7 @@ async function _copyDir(src, dest, options, parent) {
return _copyDir(childSrc, childDest, options, currentPath);
}

return copyFile(childSrc, childDest, options).thenReturn(currentPath);
return copyFile(childSrc, childDest).thenReturn(currentPath);
Copy link
Member Author

Choose a reason for hiding this comment

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

The options here is for copyDir ({ ignoreHidden, ignorePattern }) which is not related with copyFile, so I just simply remove it.

@@ -127,6 +129,7 @@ function copyFile(src, dest, flags, callback) {
if (!dest) throw new TypeError('dest is required!');
if (typeof flags === 'function') {
callback = flags;
flags = undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

Node.js 14 implemented a type check (nodejs/node@a13500f) so flags won't accept function any more.

@@ -89,6 +89,8 @@ function checkParentSync(path) {
function writeFile(path, data, options, callback) {
if (!path) throw new TypeError('path is required!');

if (!data) data = '';
Copy link
Member Author

Choose a reason for hiding this comment

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

In the test cases we use writeFile(path) to create an empty file (leave data as an undefined value) will no longer be accepted by Node.js 14.

@stevenjoezhang stevenjoezhang self-requested a review April 24, 2020 10:17
@curbengh
Copy link
Contributor

curbengh commented Apr 24, 2020

suggest to include f0deb67 in this PR and replace #59.

@SukkaW SukkaW changed the title fix: compatible with Node.js 14 ci(travis): add Node.js 14 Apr 24, 2020
@SukkaW
Copy link
Member Author

SukkaW commented Apr 24, 2020

@curbengh Done.

@SukkaW SukkaW changed the title ci(travis): add Node.js 14 fix: compatible with Node.js 14 Apr 24, 2020
@curbengh curbengh mentioned this pull request Apr 25, 2020
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

4 participants