2015-08-28 01:38:10 +05:30
|
|
|
'use strict';
|
2020-02-20 15:49:12 +08:00
|
|
|
const common = require('../common');
|
2018-03-08 02:24:08 +05:30
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
|
|
|
|
// This test ensures that fs.existsSync doesn't incorrectly return false.
|
|
|
|
// (especially on Windows)
|
|
|
|
// https://github.com/nodejs/node-v0.x-archive/issues/3739
|
|
|
|
|
2015-08-28 01:38:10 +05:30
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
2017-12-24 22:38:11 -08:00
|
|
|
let dir = path.resolve(tmpdir.path);
|
2015-08-28 01:38:10 +05:30
|
|
|
|
|
|
|
// Make sure that the tmp directory is clean
|
2017-12-24 22:38:11 -08:00
|
|
|
tmpdir.refresh();
|
2015-08-28 01:38:10 +05:30
|
|
|
|
|
|
|
// Make a long path.
|
2017-01-08 13:19:00 +00:00
|
|
|
for (let i = 0; i < 50; i++) {
|
2017-04-28 04:06:42 +03:00
|
|
|
dir = `${dir}/1234567890`;
|
2015-08-28 01:38:10 +05:30
|
|
|
}
|
|
|
|
|
2024-09-11 17:22:54 -04:00
|
|
|
fs.mkdirSync(dir, {
|
|
|
|
mode: '0777',
|
|
|
|
recursive: true,
|
|
|
|
});
|
|
|
|
|
2015-08-28 01:38:10 +05:30
|
|
|
// Test if file exists synchronously
|
2018-08-06 06:47:11 -07:00
|
|
|
assert(fs.existsSync(dir), 'Directory is not accessible');
|
2015-08-28 01:38:10 +05:30
|
|
|
|
|
|
|
// Test if file exists asynchronously
|
2020-09-06 22:27:07 +02:00
|
|
|
fs.access(dir, common.mustSucceed());
|