File tree 3 files changed +59
-0
lines changed 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -2922,6 +2922,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
2922
2922
2923
2923
for (int i = 0 ; i < legacy_main_extensions_with_main_end; i++) {
2924
2924
file_path = *initial_file_path + std::string (legacy_main_extensions[i]);
2925
+ // TODO(StefanStojanovic): Remove ifdef after
2926
+ // path.toNamespacedPath logic is ported to C++
2927
+ #ifdef _WIN32
2928
+ file_path = " \\\\ ?\\ " + file_path;
2929
+ #endif
2925
2930
2926
2931
switch (FilePathIsFile (env, file_path)) {
2927
2932
case BindingData::FilePathIsFileReturnType::kIsFile :
@@ -2959,6 +2964,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
2959
2964
i < legacy_main_extensions_package_fallback_end;
2960
2965
i++) {
2961
2966
file_path = *initial_file_path + std::string (legacy_main_extensions[i]);
2967
+ // TODO(StefanStojanovic): Remove ifdef after
2968
+ // path.toNamespacedPath logic is ported to C++
2969
+ #ifdef _WIN32
2970
+ file_path = " \\\\ ?\\ " + file_path;
2971
+ #endif
2962
2972
2963
2973
switch (FilePathIsFile (env, file_path)) {
2964
2974
case BindingData::FilePathIsFileReturnType::kIsFile :
Original file line number Diff line number Diff line change @@ -256,8 +256,15 @@ void BindingData::ReadPackageJSON(const FunctionCallbackInfo<Value>& args) {
256
256
permission::PermissionScope::kFileSystemRead ,
257
257
path.ToStringView ());
258
258
259
+ // TODO(StefanStojanovic): Remove ifdef after
260
+ // path.toNamespacedPath logic is ported to C++
261
+ #ifdef _WIN32
262
+ auto package_json = GetPackageJSON (
263
+ realm, " \\\\ ?\\ " + path.ToString (), is_esm ? &error_context : nullptr );
264
+ #else
259
265
auto package_json =
260
266
GetPackageJSON (realm, path.ToString (), is_esm ? &error_context : nullptr );
267
+ #endif
261
268
if (package_json == nullptr ) {
262
269
return ;
263
270
}
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ // Flags: --expose-internals
4
+
5
+ const common = require ( '../common' ) ;
6
+ if ( ! common . isWindows ) {
7
+ common . skip ( 'this test is Windows-specific.' ) ;
8
+ }
9
+
10
+ const fs = require ( 'fs' ) ;
11
+ const path = require ( 'path' ) ;
12
+ const tmpdir = require ( '../common/tmpdir' ) ;
13
+
14
+ // https://github.com/nodejs/node/issues/50753
15
+ // Make a path that is more than 260 chars long.
16
+ // Module layout will be the following:
17
+ // package.json
18
+ // main
19
+ // main.js
20
+
21
+ const packageDirNameLen = Math . max ( 260 - tmpdir . path . length , 1 ) ;
22
+ const packageDirName = tmpdir . resolve ( 'x' . repeat ( packageDirNameLen ) ) ;
23
+ const packageDirPath = path . resolve ( packageDirName ) ;
24
+ const packageJsonFilePath = path . join ( packageDirPath , 'package.json' ) ;
25
+ const mainDirName = 'main' ;
26
+ const mainDirPath = path . resolve ( packageDirPath , mainDirName ) ;
27
+ const mainJsFile = 'main.js' ;
28
+ const mainJsFilePath = path . resolve ( mainDirPath , mainJsFile ) ;
29
+
30
+ tmpdir . refresh ( ) ;
31
+
32
+ fs . mkdirSync ( packageDirPath ) ;
33
+ fs . writeFileSync (
34
+ packageJsonFilePath ,
35
+ `{"main":"${ mainDirName } /${ mainJsFile } "}`
36
+ ) ;
37
+ fs . mkdirSync ( mainDirPath ) ;
38
+ fs . writeFileSync ( mainJsFilePath , 'console.log("hello world");' ) ;
39
+
40
+ require ( 'internal/modules/run_main' ) . executeUserEntryPoint ( packageDirPath ) ;
41
+
42
+ tmpdir . refresh ( ) ;
You can’t perform that action at this time.
0 commit comments