GeezerVison is showing github.com — test: remove common.fileExists() · nodejs/node@0385e09
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -121,12 +121,6 @@ Tests whether `name`, `expected`, and `code` are part of a raised warning. If | 121 | 121 | an expected warning does not have a code then `common.noWarnCode` can be used | 122 | 122 | to indicate this. | 123 | 123 |
| 124 | | -### fileExists(pathname) | 125 | | -* pathname [<string>] | 126 | | -* return [<boolean>] | 127 | | - | 128 | | -Checks if `pathname` exists | 129 | | - | 130 | 124 | ### getArrayBufferViews(buf) | 131 | 125 | * `buf` [<Buffer>] | 132 | 126 | * return [<ArrayBufferView[]>] | |
Collapse file Copy file name to clipboardExpand all lines: test/common/index.js +1-10Lines changed: 1 addition & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -477,17 +477,8 @@ exports.hasMultiLocalhost = function hasMultiLocalhost() { | 477 | 477 | return ret === 0; | 478 | 478 | }; | 479 | 479 |
| 480 | | -exports.fileExists = function(pathname) { | 481 | | - try { | 482 | | - fs.accessSync(pathname); | 483 | | - return true; | 484 | | - } catch (err) { | 485 | | - return false; | 486 | | - } | 487 | | -}; | 488 | | - | 489 | 480 | exports.skipIfEslintMissing = function() { | 490 | | - if (!exports.fileExists( | | 481 | + if (!fs.existsSync( | 491 | 482 | path.join(__dirname, '..', '..', 'tools', 'node_modules', 'eslint') | 492 | 483 | )) { | 493 | 484 | exports.skip('missing ESLint'); | |
Collapse file Copy file name to clipboardExpand all lines: test/common/index.mjs -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,7 +33,6 @@ const { | 33 | 33 | mustCallAtLeast, | 34 | 34 | mustCallAsync, | 35 | 35 | hasMultiLocalhost, | 36 | | - fileExists, | 37 | 36 | skipIfEslintMissing, | 38 | 37 | canCreateSymLink, | 39 | 38 | getCallSite, | @@ -92,7 +91,6 @@ export { | 92 | 91 | mustCallAtLeast, | 93 | 92 | mustCallAsync, | 94 | 93 | hasMultiLocalhost, | 95 | | - fileExists, | 96 | 94 | skipIfEslintMissing, | 97 | 95 | canCreateSymLink, | 98 | 96 | getCallSite, | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
| 23 | 23 | const common = require('../common'); | 24 | 24 | const spawn = require('child_process').spawn; | 25 | 25 | const assert = require('assert'); | | 26 | +const fs = require('fs'); | 26 | 27 |
| 27 | 28 | const enoentPath = 'foo123'; | 28 | 29 | const spawnargs = ['bar']; | 29 | | -assert.strictEqual(common.fileExists(enoentPath), false); | | 30 | +assert.strictEqual(fs.existsSync(enoentPath), false); | 30 | 31 |
| 31 | 32 | const enoentChild = spawn(enoentPath, spawnargs); | 32 | 33 | enoentChild.on('error', common.mustCall(function(err) { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-existssync-false.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | | -const common = require('../common'); | | 2 | +require('../common'); | 3 | 3 | const tmpdir = require('../common/tmpdir'); | 4 | 4 |
| 5 | 5 | // This test ensures that fs.existsSync doesn't incorrectly return false. | @@ -28,7 +28,7 @@ for (let i = 0; i < 50; i++) { | 28 | 28 | } | 29 | 29 |
| 30 | 30 | // Test if file exists synchronously | 31 | | -assert(common.fileExists(dir), 'Directory is not accessible'); | | 31 | +assert(fs.existsSync(dir), 'Directory is not accessible'); | 32 | 32 |
| 33 | 33 | // Test if file exists asynchronously | 34 | 34 | fs.access(dir, function(err) { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-mkdir-rmdir.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,19 +10,19 @@ const d = path.join(tmpdir.path, 'dir'); | 10 | 10 | tmpdir.refresh(); | 11 | 11 |
| 12 | 12 | // Make sure the directory does not exist | 13 | | -assert(!common.fileExists(d)); | | 13 | +assert(!fs.existsSync(d)); | 14 | 14 | // Create the directory now | 15 | 15 | fs.mkdirSync(d); | 16 | 16 | // Make sure the directory exists | 17 | | -assert(common.fileExists(d)); | | 17 | +assert(fs.existsSync(d)); | 18 | 18 | // Try creating again, it should fail with EEXIST | 19 | 19 | assert.throws(function() { | 20 | 20 | fs.mkdirSync(d); | 21 | 21 | }, /EEXIST: file already exists, mkdir/); | 22 | 22 | // Remove the directory now | 23 | 23 | fs.rmdirSync(d); | 24 | 24 | // Make sure the directory does not exist | 25 | | -assert(!common.fileExists(d)); | | 25 | +assert(!fs.existsSync(d)); | 26 | 26 |
| 27 | 27 | // Similarly test the Async version | 28 | 28 | fs.mkdir(d, 0o666, common.mustCall(function(err) { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-mkdir.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,7 @@ tmpdir.refresh(); | 32 | 32 |
| 33 | 33 | fs.mkdir(pathname, common.mustCall(function(err) { | 34 | 34 | assert.strictEqual(err, null); | 35 | | - assert.strictEqual(common.fileExists(pathname), true); | | 35 | + assert.strictEqual(fs.existsSync(pathname), true); | 36 | 36 | })); | 37 | 37 | } | 38 | 38 |
| @@ -41,7 +41,7 @@ tmpdir.refresh(); | 41 | 41 |
| 42 | 42 | fs.mkdir(pathname, 0o777, common.mustCall(function(err) { | 43 | 43 | assert.strictEqual(err, null); | 44 | | - assert.strictEqual(common.fileExists(pathname), true); | | 44 | + assert.strictEqual(fs.existsSync(pathname), true); | 45 | 45 | })); | 46 | 46 | } | 47 | 47 |
| @@ -50,7 +50,7 @@ tmpdir.refresh(); | 50 | 50 |
| 51 | 51 | fs.mkdirSync(pathname); | 52 | 52 |
| 53 | | - const exists = common.fileExists(pathname); | | 53 | + const exists = fs.existsSync(pathname); | 54 | 54 | assert.strictEqual(exists, true); | 55 | 55 | } | 56 | 56 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-mkdtemp.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,16 +11,16 @@ tmpdir.refresh(); | 11 | 11 | const tmpFolder = fs.mkdtempSync(path.join(tmpdir.path, 'foo.')); | 12 | 12 |
| 13 | 13 | assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length); | 14 | | -assert(common.fileExists(tmpFolder)); | | 14 | +assert(fs.existsSync(tmpFolder)); | 15 | 15 |
| 16 | 16 | const utf8 = fs.mkdtempSync(path.join(tmpdir.path, '\u0222abc.')); | 17 | 17 | assert.strictEqual(Buffer.byteLength(path.basename(utf8)), | 18 | 18 | Buffer.byteLength('\u0222abc.XXXXXX')); | 19 | | -assert(common.fileExists(utf8)); | | 19 | +assert(fs.existsSync(utf8)); | 20 | 20 |
| 21 | 21 | function handler(err, folder) { | 22 | 22 | assert.ifError(err); | 23 | | - assert(common.fileExists(folder)); | | 23 | + assert(fs.existsSync(folder)); | 24 | 24 | assert.strictEqual(this, undefined); | 25 | 25 | } | 26 | 26 |
| |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -47,8 +47,8 @@ fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) { | 47 | 47 |
| 48 | 48 | fs.unlink(linkPath, common.mustCall(function(err) { | 49 | 49 | assert.ifError(err); | 50 | | - assert(!common.fileExists(linkPath)); | 51 | | - assert(common.fileExists(linkData)); | | 50 | + assert(!fs.existsSync(linkPath)); | | 51 | + assert(fs.existsSync(linkData)); | 52 | 52 | })); | 53 | 53 | })); | 54 | 54 | })); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-require-exceptions.js +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | 21 |
| 22 | 22 | 'use strict'; | 23 | | -const common = require('../common'); | | 23 | +require('../common'); | 24 | 24 | const assert = require('assert'); | | 25 | +const fs = require('fs'); | 25 | 26 | const fixtures = require('../common/fixtures'); | 26 | 27 |
| 27 | 28 | // A module with an error in it should throw | @@ -52,5 +53,5 @@ function assertModuleNotFound(path) { | 52 | 53 | } | 53 | 54 |
| 54 | 55 | function assertExists(fixture) { | 55 | | - assert(common.fileExists(fixtures.path(fixture))); | | 56 | + assert(fs.existsSync(fixtures.path(fixture))); | 56 | 57 | } |
|