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

src: use wide string for findPackageJson onWindows #55861

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

islandryu
Copy link
Contributor

Fix error when searching for package.json with non-ASCII characters in paths

Fixes: #55773

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Nov 15, 2024
@aduh95
Copy link
Contributor

aduh95 commented Nov 15, 2024

Can you add a test?

Fix error when searching for package.json with non-ASCII characters in
paths

Fixes: nodejs#55773
Comment on lines 11 to 15
fs.mkdirSync(tmpdir.resolve('12月'), { recursive: true });
fs.writeFileSync(
tmpdir.resolve('12月/index.js'),
"console.log('12月');",
);
Copy link
Member

Choose a reason for hiding this comment

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

This can be a fixture, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I should do that.

test/parallel/test-non-ascii.js Outdated Show resolved Hide resolved
test/parallel/test-non-ascii.js Outdated Show resolved Hide resolved
test/parallel/test-non-ascii.js Outdated Show resolved Hide resolved
test/parallel/test-non-ascii.js Outdated Show resolved Hide resolved
islandryu and others added 4 commits November 15, 2024 23:26
Co-authored-by: Aviv Keller <redyetidev@gmail.com>
Co-authored-by: Aviv Keller <redyetidev@gmail.com>
Co-authored-by: Aviv Keller <redyetidev@gmail.com>
Co-authored-by: Aviv Keller <redyetidev@gmail.com>
'use strict';

const fs = require('node:fs');
const common = require('../common');
Copy link
Member

@RedYetiDev RedYetiDev Nov 15, 2024

Choose a reason for hiding this comment

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

Common must be the first import. FWIW running make lint will catch this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for the lint error.
I've fixed it.

@islandryu islandryu marked this pull request as ready for review November 15, 2024 14:54
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.43%. Comparing base (b02cd41) to head (2ad8502).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/node_modules.cc 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #55861   +/-   ##
=======================================
  Coverage   88.42%   88.43%           
=======================================
  Files         654      654           
  Lines      187852   187850    -2     
  Branches    36134    36134           
=======================================
+ Hits       166102   166117   +15     
+ Misses      14989    14982    -7     
+ Partials     6761     6751   -10     
Files with missing lines Coverage Δ
src/node_file.cc 77.35% <ø> (ø)
src/util.cc 87.39% <ø> (ø)
src/util.h 91.22% <ø> (ø)
src/node_modules.cc 78.64% <83.33%> (-0.14%) ⬇️

... and 17 files with indirect coverage changes

std::wstring ConvertToWideString(const std::string& str);

#define BufferValueToPath(str) \
std::filesystem::path(ConvertToWideString(str.ToString()))
Copy link
Member

Choose a reason for hiding this comment

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

These macros are unnecessary. Also, str.ToString() makes an unnecessary copy, even tho, the function is const std::string&. str.ToStringView() would remove the unnecessary copy here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
5 participants