The usage of `new Array(length + 1).join(str)` is strange. Change to `str.repeat(length)` is more clearly. PR-URL: https://github.com/nodejs/node/pull/11071 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
34 lines
815 B
JavaScript
34 lines
815 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const assert = require('assert');
|
|
|
|
if (!common.isWindows) {
|
|
common.skip('this test is Windows-specific.');
|
|
return;
|
|
}
|
|
|
|
// make a path that will be at least 260 chars long.
|
|
const fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
|
|
const fileName = path.join(common.tmpDir, 'x'.repeat(fileNameLen));
|
|
const fullPath = path.resolve(fileName);
|
|
|
|
common.refreshTmpDir();
|
|
|
|
console.log({
|
|
filenameLength: fileName.length,
|
|
fullPathLength: fullPath.length
|
|
});
|
|
|
|
fs.writeFile(fullPath, 'ok', common.mustCall(function(err) {
|
|
assert.ifError(err);
|
|
|
|
fs.stat(fullPath, common.mustCall(function(err, stats) {
|
|
assert.ifError(err);
|
|
}));
|
|
}));
|
|
|
|
process.on('exit', function() {
|
|
fs.unlinkSync(fullPath);
|
|
});
|