GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: remove common.fileExists() · nodejs/node@0385e09

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • common
      • README.md
      • index.js
      • index.mjs
    • parallel
      • test-child-process-spawn-error.js
      • test-fs-existssync-false.js
      • test-fs-mkdir-rmdir.js
      • test-fs-mkdir.js
      • test-fs-mkdtemp.js
      • test-fs-symlink-dir-junction.js
      • test-require-exceptions.js
      • test-trace-events-all.js
      • test-trace-events-api.js
      • test-trace-events-async-hooks.js
      • test-trace-events-binding.js
      • test-trace-events-bootstrap.js
      • test-trace-events-file-pattern.js
      • test-trace-events-fs-sync.js
      • test-trace-events-metadata.js
      • test-trace-events-none.js
      • test-trace-events-perf.js
      • test-trace-events-process-exit.js
      • test-trace-events-v8.js
      • test-trace-events-vm.js
      • test-trace-events-worker-metadata.js
    • pummel
      • test-fs-watch-file-slow.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/common/README.md‎

Copy file name to clipboardExpand all lines: test/common/README.md
-6Lines changed: 0 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ Tests whether `name`, `expected`, and `code` are part of a raised warning. If
121121
an expected warning does not have a code then `common.noWarnCode` can be used
122122
to indicate this.
123123

124-
### fileExists(pathname)
125-
* pathname [<string>]
126-
* return [<boolean>]
127-
128-
Checks if `pathname` exists
129-
130124
### getArrayBufferViews(buf)
131125
* `buf` [<Buffer>]
132126
* return [<ArrayBufferView[]>]
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,8 @@ exports.hasMultiLocalhost = function hasMultiLocalhost() {
477477
return ret === 0;
478478
};
479479

480-
exports.fileExists = function(pathname) {
481-
try {
482-
fs.accessSync(pathname);
483-
return true;
484-
} catch (err) {
485-
return false;
486-
}
487-
};
488-
489480
exports.skipIfEslintMissing = function() {
490-
if (!exports.fileExists(
481+
if (!fs.existsSync(
491482
path.join(__dirname, '..', '..', 'tools', 'node_modules', 'eslint')
492483
)) {
493484
exports.skip('missing ESLint');
Collapse file

‎test/common/index.mjs‎

Copy file name to clipboardExpand all lines: test/common/index.mjs
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const {
3333
mustCallAtLeast,
3434
mustCallAsync,
3535
hasMultiLocalhost,
36-
fileExists,
3736
skipIfEslintMissing,
3837
canCreateSymLink,
3938
getCallSite,
@@ -92,7 +91,6 @@ export {
9291
mustCallAtLeast,
9392
mustCallAsync,
9493
hasMultiLocalhost,
95-
fileExists,
9694
skipIfEslintMissing,
9795
canCreateSymLink,
9896
getCallSite,
Collapse file

‎test/parallel/test-child-process-spawn-error.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawn-error.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
const common = require('../common');
2424
const spawn = require('child_process').spawn;
2525
const assert = require('assert');
26+
const fs = require('fs');
2627

2728
const enoentPath = 'foo123';
2829
const spawnargs = ['bar'];
29-
assert.strictEqual(common.fileExists(enoentPath), false);
30+
assert.strictEqual(fs.existsSync(enoentPath), false);
3031

3132
const enoentChild = spawn(enoentPath, spawnargs);
3233
enoentChild.on('error', common.mustCall(function(err) {
Collapse file

‎test/parallel/test-fs-existssync-false.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-existssync-false.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const common = require('../common');
2+
require('../common');
33
const tmpdir = require('../common/tmpdir');
44

55
// This test ensures that fs.existsSync doesn't incorrectly return false.
@@ -28,7 +28,7 @@ for (let i = 0; i < 50; i++) {
2828
}
2929

3030
// Test if file exists synchronously
31-
assert(common.fileExists(dir), 'Directory is not accessible');
31+
assert(fs.existsSync(dir), 'Directory is not accessible');
3232

3333
// Test if file exists asynchronously
3434
fs.access(dir, function(err) {
Collapse file

‎test/parallel/test-fs-mkdir-rmdir.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-mkdir-rmdir.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ const d = path.join(tmpdir.path, 'dir');
1010
tmpdir.refresh();
1111

1212
// Make sure the directory does not exist
13-
assert(!common.fileExists(d));
13+
assert(!fs.existsSync(d));
1414
// Create the directory now
1515
fs.mkdirSync(d);
1616
// Make sure the directory exists
17-
assert(common.fileExists(d));
17+
assert(fs.existsSync(d));
1818
// Try creating again, it should fail with EEXIST
1919
assert.throws(function() {
2020
fs.mkdirSync(d);
2121
}, /EEXIST: file already exists, mkdir/);
2222
// Remove the directory now
2323
fs.rmdirSync(d);
2424
// Make sure the directory does not exist
25-
assert(!common.fileExists(d));
25+
assert(!fs.existsSync(d));
2626

2727
// Similarly test the Async version
2828
fs.mkdir(d, 0o666, common.mustCall(function(err) {
Collapse file

‎test/parallel/test-fs-mkdir.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-mkdir.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tmpdir.refresh();
3232

3333
fs.mkdir(pathname, common.mustCall(function(err) {
3434
assert.strictEqual(err, null);
35-
assert.strictEqual(common.fileExists(pathname), true);
35+
assert.strictEqual(fs.existsSync(pathname), true);
3636
}));
3737
}
3838

@@ -41,7 +41,7 @@ tmpdir.refresh();
4141

4242
fs.mkdir(pathname, 0o777, common.mustCall(function(err) {
4343
assert.strictEqual(err, null);
44-
assert.strictEqual(common.fileExists(pathname), true);
44+
assert.strictEqual(fs.existsSync(pathname), true);
4545
}));
4646
}
4747

@@ -50,7 +50,7 @@ tmpdir.refresh();
5050

5151
fs.mkdirSync(pathname);
5252

53-
const exists = common.fileExists(pathname);
53+
const exists = fs.existsSync(pathname);
5454
assert.strictEqual(exists, true);
5555
}
5656

Collapse file

‎test/parallel/test-fs-mkdtemp.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-mkdtemp.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ tmpdir.refresh();
1111
const tmpFolder = fs.mkdtempSync(path.join(tmpdir.path, 'foo.'));
1212

1313
assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length);
14-
assert(common.fileExists(tmpFolder));
14+
assert(fs.existsSync(tmpFolder));
1515

1616
const utf8 = fs.mkdtempSync(path.join(tmpdir.path, '\u0222abc.'));
1717
assert.strictEqual(Buffer.byteLength(path.basename(utf8)),
1818
Buffer.byteLength('\u0222abc.XXXXXX'));
19-
assert(common.fileExists(utf8));
19+
assert(fs.existsSync(utf8));
2020

2121
function handler(err, folder) {
2222
assert.ifError(err);
23-
assert(common.fileExists(folder));
23+
assert(fs.existsSync(folder));
2424
assert.strictEqual(this, undefined);
2525
}
2626

Collapse file

‎test/parallel/test-fs-symlink-dir-junction.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-symlink-dir-junction.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) {
4747

4848
fs.unlink(linkPath, common.mustCall(function(err) {
4949
assert.ifError(err);
50-
assert(!common.fileExists(linkPath));
51-
assert(common.fileExists(linkData));
50+
assert(!fs.existsSync(linkPath));
51+
assert(fs.existsSync(linkData));
5252
}));
5353
}));
5454
}));
Collapse file

‎test/parallel/test-require-exceptions.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-require-exceptions.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
const common = require('../common');
23+
require('../common');
2424
const assert = require('assert');
25+
const fs = require('fs');
2526
const fixtures = require('../common/fixtures');
2627

2728
// A module with an error in it should throw
@@ -52,5 +53,5 @@ function assertModuleNotFound(path) {
5253
}
5354

5455
function assertExists(fixture) {
55-
assert(common.fileExists(fixtures.path(fixture)));
56+
assert(fs.existsSync(fixtures.path(fixture)));
5657
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.