-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: fix stat with long paths on Windows
- Loading branch information
Showing
2 changed files
with
17 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var assert = require('assert'); | ||
const common = require('../common'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// make a path that is more than 260 chars long. | ||
var fileNameLen = Math.max(261 - common.tmpDir.length - 1, 1); | ||
var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x')); | ||
var fullPath = path.resolve(fileName); | ||
const dirNameLen = Math.max(260 - common.tmpDir.length, 1); | ||
const dirName = path.join(common.tmpDir, 'x'.repeat(dirNameLen)); | ||
const fullDirPath = path.resolve(dirName); | ||
|
||
const indexFile = path.join(fullDirPath, 'index.js'); | ||
const otherFile = path.join(fullDirPath, 'other.js'); | ||
|
||
common.refreshTmpDir(); | ||
fs.writeFileSync(fullPath, 'module.exports = 42;'); | ||
|
||
assert.equal(require(fullPath), 42); | ||
fs.mkdirSync(fullDirPath); | ||
fs.writeFileSync(indexFile, 'require("./other");'); | ||
fs.writeFileSync(otherFile, ''); | ||
|
||
require(indexFile); | ||
require(otherFile); | ||
|
||
fs.unlinkSync(fullPath); | ||
common.refreshTmpDir(); |