0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/test/parallel/test-require-long-path.js
Michaël Zasso a4f4909f3d module: fix stat with long paths on Windows
PR-URL: https://github.com/nodejs/io.js/pull/2013
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-22 22:03:31 +10:00

24 lines
639 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const path = require('path');
// make a path that is more than 260 chars long.
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.mkdirSync(fullDirPath);
fs.writeFileSync(indexFile, 'require("./other");');
fs.writeFileSync(otherFile, '');
require(indexFile);
require(otherFile);
common.refreshTmpDir();