Skip to content

Commit 671e64a

Browse files
targospiscisaureus
authored andcommitted
module: allow long paths for require on Windows
#1801 introduced internal fs methods to speed up require. The methods do not call path._makeLong like their counterpart from the fs module. This brings back the old behaviour. Fixes: #1990Fixes: #1980Fixes: #1849 PR-URL: https://github.com/nodejs/io.js/pull/1991/files Reviewed-By: Bert Belder <[email protected]>
1 parent 52a822d commit 671e64a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

‎lib/module.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function readPackage(requestPath){
6767
}
6868

6969
varjsonPath=path.resolve(requestPath,'package.json');
70-
varjson=internalModuleReadFile(jsonPath);
70+
varjson=internalModuleReadFile(path._makeLong(jsonPath));
7171

7272
if(json===undefined){
7373
returnfalse;
@@ -100,7 +100,7 @@ Module._realpathCache ={};
100100

101101
// check if the file exists and is not a directory
102102
functiontryFile(requestPath){
103-
constrc=internalModuleStat(requestPath);
103+
constrc=internalModuleStat(path._makeLong(requestPath));
104104
returnrc===0&&toRealPath(requestPath);
105105
}
106106

@@ -146,7 +146,7 @@ Module._findPath = function(request, paths){
146146
varfilename;
147147

148148
if(!trailingSlash){
149-
constrc=internalModuleStat(basePath);
149+
constrc=internalModuleStat(path._makeLong(basePath));
150150
if(rc===0){// File.
151151
filename=toRealPath(basePath);
152152
}elseif(rc===1){// Directory.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
varcommon=require('../common');
3+
varfs=require('fs');
4+
varpath=require('path');
5+
varassert=require('assert');
6+
7+
// make a path that is more than 260 chars long.
8+
varfileNameLen=Math.max(261-common.tmpDir.length-1,1);
9+
varfileName=path.join(common.tmpDir,newArray(fileNameLen+1).join('x'));
10+
varfullPath=path.resolve(fileName);
11+
12+
common.refreshTmpDir();
13+
fs.writeFileSync(fullPath,'module.exports = 42;');
14+
15+
assert.equal(require(fullPath),42);
16+
17+
fs.unlinkSync(fullPath);

0 commit comments

Comments
(0)