| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent db7b27a commit b1c742e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,19 +3,19 @@ const common = require('../common'); | |||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const fs = require('fs'); | |
| 5 | 5 | const path = require('path'); | |
| 6 | - var doesNotExist = path.join(common.tmpDir, '__this_should_not_exist'); | ||
| 7 | - var readOnlyFile = path.join(common.tmpDir, 'read_only_file'); | ||
| 8 | - var readWriteFile = path.join(common.tmpDir, 'read_write_file'); | ||
| 6 | + const doesNotExist = path.join(common.tmpDir, '__this_should_not_exist'); | ||
| 7 | + const readOnlyFile = path.join(common.tmpDir, 'read_only_file'); | ||
| 8 | + const readWriteFile = path.join(common.tmpDir, 'read_write_file'); | ||
| 9 | 9 | ||
| 10 | - var removeFile = function(file) { | ||
| 10 | + const removeFile = function(file) { | ||
| 11 | 11 | try { | |
| 12 | 12 | fs.unlinkSync(file); | |
| 13 | 13 | } catch (err) { | |
| 14 | 14 | // Ignore error | |
| 15 | 15 | } | |
| 16 | 16 | }; | |
| 17 | 17 | ||
| 18 | - var createFileWithPerms = function(file, mode) { | ||
| 18 | + const createFileWithPerms = function(file, mode) { | ||
| 19 | 19 | removeFile(file); | |
| 20 | 20 | fs.writeFileSync(file, ''); | |
| 21 | 21 | fs.chmodSync(file, mode); | |
@@ -48,7 +48,7 @@ createFileWithPerms(readWriteFile, 0o666); | |||
| 48 | 48 | * id, but that's fine. In this case, it is the responsability of the | |
| 49 | 49 | * continuous integration platform to take care of that. | |
| 50 | 50 | */ | |
| 51 | - var hasWriteAccessForReadonlyFile = false; | ||
| 51 | + let hasWriteAccessForReadonlyFile = false; | ||
| 52 | 52 | if (!common.isWindows && process.getuid() === 0) { | |
| 53 | 53 | hasWriteAccessForReadonlyFile = true; | |
| 54 | 54 | try { | |
@@ -63,62 +63,62 @@ assert.strictEqual(typeof fs.R_OK, 'number'); | |||
| 63 | 63 | assert.strictEqual(typeof fs.W_OK, 'number'); | |
| 64 | 64 | assert.strictEqual(typeof fs.X_OK, 'number'); | |
| 65 | 65 | ||
| 66 | - fs.access(__filename, function(err) { | ||
| 67 | - assert.strictEqual(err, null, 'error should not exist'); | ||
| 68 | - }); | ||
| 66 | + fs.access(__filename, common.mustCall((err) => { | ||
| 67 | + assert.ifError(err); | ||
| 68 | + })); | ||
| 69 | 69 | ||
| 70 | - fs.access(__filename, fs.R_OK, function(err) { | ||
| 71 | - assert.strictEqual(err, null, 'error should not exist'); | ||
| 72 | - }); | ||
| 70 | + fs.access(__filename, fs.R_OK, common.mustCall((err) => { | ||
| 71 | + assert.ifError(err); | ||
| 72 | + })); | ||
| 73 | 73 | ||
| 74 | - fs.access(doesNotExist, function(err) { | ||
| 74 | + fs.access(doesNotExist, common.mustCall((err) => { | ||
| 75 | 75 | assert.notEqual(err, null, 'error should exist'); | |
| 76 | 76 | assert.strictEqual(err.code, 'ENOENT'); | |
| 77 | 77 | assert.strictEqual(err.path, doesNotExist); | |
| 78 | - }); | ||
| 78 | + })); | ||
| 79 | 79 | ||
| 80 | - fs.access(readOnlyFile, fs.F_OK | fs.R_OK, function(err) { | ||
| 81 | - assert.strictEqual(err, null, 'error should not exist'); | ||
| 82 | - }); | ||
| 80 | + fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall((err) => { | ||
| 81 | + assert.ifError(err); | ||
| 82 | + })); | ||
| 83 | 83 | ||
| 84 | - fs.access(readOnlyFile, fs.W_OK, function(err) { | ||
| 84 | + fs.access(readOnlyFile, fs.W_OK, common.mustCall((err) => { | ||
| 85 | 85 | if (hasWriteAccessForReadonlyFile) { | |
| 86 | - assert.equal(err, null, 'error should not exist'); | ||
| 86 | + assert.ifError(err); | ||
| 87 | 87 | } else { | |
| 88 | 88 | assert.notEqual(err, null, 'error should exist'); | |
| 89 | 89 | assert.strictEqual(err.path, readOnlyFile); | |
| 90 | 90 | } | |
| 91 | - }); | ||
| 91 | + })); | ||
| 92 | 92 | ||
| 93 | - assert.throws(function() { | ||
| 94 | - fs.access(100, fs.F_OK, function(err) {}); | ||
| 93 | + assert.throws(() => { | ||
| 94 | + fs.access(100, fs.F_OK, (err) => {}); | ||
| 95 | 95 | }, /path must be a string or Buffer/); | |
| 96 | 96 | ||
| 97 | - assert.throws(function() { | ||
| 97 | + assert.throws(() => { | ||
| 98 | 98 | fs.access(__filename, fs.F_OK); | |
| 99 | 99 | }, /"callback" argument must be a function/); | |
| 100 | 100 | ||
| 101 | - assert.throws(function() { | ||
| 101 | + assert.throws(() => { | ||
| 102 | 102 | fs.access(__filename, fs.F_OK, {}); | |
| 103 | 103 | }, /"callback" argument must be a function/); | |
| 104 | 104 | ||
| 105 | - assert.doesNotThrow(function() { | ||
| 105 | + assert.doesNotThrow(() => { | ||
| 106 | 106 | fs.accessSync(__filename); | |
| 107 | 107 | }); | |
| 108 | 108 | ||
| 109 | - assert.doesNotThrow(function() { | ||
| 109 | + assert.doesNotThrow(() => { | ||
| 110 | 110 | var mode = fs.F_OK | fs.R_OK | fs.W_OK; | |
| 111 | 111 | ||
| 112 | 112 | fs.accessSync(readWriteFile, mode); | |
| 113 | 113 | }); | |
| 114 | 114 | ||
| 115 | - assert.throws(function() { | ||
| 115 | + assert.throws(() => { | ||
| 116 | 116 | fs.accessSync(doesNotExist); | |
| 117 | - }, function(err) { | ||
| 117 | + }, (err) => { | ||
| 118 | 118 | return err.code === 'ENOENT' && err.path === doesNotExist; | |
| 119 | 119 | }); | |
| 120 | 120 | ||
| 121 | - process.on('exit', function() { | ||
| 121 | + process.on('exit', () => { | ||
| 122 | 122 | removeFile(readOnlyFile); | |
| 123 | 123 | removeFile(readWriteFile); | |
| 124 | 124 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments