diff --git a/lib/copy-sync/__tests__/copy-sync-file.test.js b/lib/copy-sync/__tests__/copy-sync-file.test.js index 5044214e..1218fce8 100644 --- a/lib/copy-sync/__tests__/copy-sync-file.test.js +++ b/lib/copy-sync/__tests__/copy-sync-file.test.js @@ -57,7 +57,7 @@ describe('+ copySync() / file', () => { const fileDest = path.join(TEST_DIR, 'TEST_fs-extra_copy') fs.writeFileSync(fileSrc, crypto.randomBytes(SIZE)) - fs.chmodSync(fileSrc, parseInt('750', 8)) + fs.chmodSync(fileSrc, 0o750) fs.copySync(fileSrc, fileDest) const statSrc = fs.statSync(fileSrc) @@ -187,7 +187,7 @@ describe('+ copySync() / file', () => { describe('> when overwrite is true and dest is readonly', () => { it('should copy the file and not throw an error', () => { try { - fs.chmodSync(dest, parseInt('444', 8)) + fs.chmodSync(dest, 0o444) fs.copySync(src, dest, { overwrite: true }) destData = fs.readFileSync(dest, 'utf8') assert.strictEqual(srcData, destData) diff --git a/lib/copy/__tests__/copy-permissions.test.js b/lib/copy/__tests__/copy-permissions.test.js index ccc89cd2..f14bf023 100644 --- a/lib/copy/__tests__/copy-permissions.test.js +++ b/lib/copy/__tests__/copy-permissions.test.js @@ -8,10 +8,6 @@ const assert = require('assert') /* global beforeEach, describe, it */ -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) -const o444 = parseInt('444', 8) - describe('copy', () => { let TEST_DIR @@ -27,8 +23,8 @@ describe('copy', () => { // var userid = require('userid') // http://man7.org/linux/man-pages/man2/stat.2.html - const S_IFREG = parseInt('0100000', 8) // regular file - const S_IFDIR = parseInt('0040000', 8) // directory + const S_IFREG = 0o100000 // regular file + const S_IFDIR = 0o40000 // directory // these are Mac specific I think (at least staff), should find Linux equivalent let gidWheel @@ -54,31 +50,31 @@ describe('copy', () => { const f1 = path.join(srcDir, 'f1.txt') fs.writeFileSync(f1, '') - fs.chmodSync(f1, o666) + fs.chmodSync(f1, 0o666) fs.chownSync(f1, process.getuid(), gidWheel) const f1stats = fs.lstatSync(f1) - assert.strictEqual(f1stats.mode - S_IFREG, o666) + assert.strictEqual(f1stats.mode - S_IFREG, 0o666) const d1 = path.join(srcDir, 'somedir') fs.mkdirSync(d1) - fs.chmodSync(d1, o777) + fs.chmodSync(d1, 0o777) fs.chownSync(d1, process.getuid(), gidStaff) const d1stats = fs.lstatSync(d1) - assert.strictEqual(d1stats.mode - S_IFDIR, o777) + assert.strictEqual(d1stats.mode - S_IFDIR, 0o777) const f2 = path.join(d1, 'f2.bin') fs.writeFileSync(f2, '') - fs.chmodSync(f2, o777) + fs.chmodSync(f2, 0o777) fs.chownSync(f2, process.getuid(), gidStaff) const f2stats = fs.lstatSync(f2) - assert.strictEqual(f2stats.mode - S_IFREG, o777) + assert.strictEqual(f2stats.mode - S_IFREG, 0o777) const d2 = path.join(srcDir, 'crazydir') fs.mkdirSync(d2) - fs.chmodSync(d2, o444) + fs.chmodSync(d2, 0o444) fs.chownSync(d2, process.getuid(), gidWheel) const d2stats = fs.lstatSync(d2) - assert.strictEqual(d2stats.mode - S_IFDIR, o444) + assert.strictEqual(d2stats.mode - S_IFDIR, 0o444) const destDir = path.join(permDir, 'dest') fse.copy(srcDir, destDir, err => { diff --git a/lib/copy/__tests__/ncp/ncp-error-perm.test.js b/lib/copy/__tests__/ncp/ncp-error-perm.test.js index a31a43dd..49bef1f9 100644 --- a/lib/copy/__tests__/ncp/ncp-error-perm.test.js +++ b/lib/copy/__tests__/ncp/ncp-error-perm.test.js @@ -37,7 +37,7 @@ describe('ncp / error / dest-permission', () => { fse.outputFileSync(someFile, 'hello') fse.mkdirsSync(dest) - fs.chmodSync(dest, parseInt('444', 8)) + fs.chmodSync(dest, 0o444) const subdest = path.join(dest, 'another-dir') diff --git a/lib/mkdirs/__tests__/chmod.test.js b/lib/mkdirs/__tests__/chmod.test.js index 19cb4019..5496427e 100644 --- a/lib/mkdirs/__tests__/chmod.test.js +++ b/lib/mkdirs/__tests__/chmod.test.js @@ -8,11 +8,6 @@ const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -const o755 = parseInt('755', 8) -const o744 = parseInt('744', 8) -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) - describe('mkdirp / chmod', () => { let TEST_DIR let TEST_SUBDIR @@ -35,7 +30,7 @@ describe('mkdirp / chmod', () => { afterEach(done => fse.remove(TEST_DIR, done)) it('chmod-pre', done => { - const mode = o744 + const mode = 0o744 fse.mkdirp(TEST_SUBDIR, mode, err => { assert.ifError(err, 'should not error') fs.stat(TEST_SUBDIR, (err, stat) => { @@ -43,9 +38,9 @@ describe('mkdirp / chmod', () => { assert.ok(stat && stat.isDirectory(), 'should be directory') if (os.platform().indexOf('win') === 0) { - assert.strictEqual(stat && stat.mode & o777, o666, 'windows shit') + assert.strictEqual(stat && stat.mode & 0o777, 0o666, 'windows shit') } else { - assert.strictEqual(stat && stat.mode & o777, mode, 'should be 0744') + assert.strictEqual(stat && stat.mode & 0o777, mode, 'should be 0744') } done() @@ -54,7 +49,7 @@ describe('mkdirp / chmod', () => { }) it('chmod', done => { - const mode = o755 + const mode = 0o755 fse.mkdirp(TEST_SUBDIR, mode, err => { assert.ifError(err, 'should not error') fs.stat(TEST_SUBDIR, (err, stat) => { diff --git a/lib/mkdirs/__tests__/clobber.test.js b/lib/mkdirs/__tests__/clobber.test.js index f359cebf..b932b040 100644 --- a/lib/mkdirs/__tests__/clobber.test.js +++ b/lib/mkdirs/__tests__/clobber.test.js @@ -8,8 +8,6 @@ const assert = require('assert') /* global before, describe, it */ -const o755 = parseInt('755', 8) - describe('mkdirp / clobber', () => { let TEST_DIR let file @@ -42,7 +40,7 @@ describe('mkdirp / clobber', () => { }) it('should clobber', done => { - fse.mkdirp(file, o755, err => { + fse.mkdirp(file, 0o755, err => { assert.ok(err) if (os.platform().indexOf('win') === 0) { assert.strictEqual(err.code, 'EEXIST') diff --git a/lib/mkdirs/__tests__/mkdirp.test.js b/lib/mkdirs/__tests__/mkdirp.test.js index 4ec42609..2af572a3 100644 --- a/lib/mkdirs/__tests__/mkdirp.test.js +++ b/lib/mkdirs/__tests__/mkdirp.test.js @@ -8,10 +8,6 @@ const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -const o755 = parseInt('755', 8) -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) - describe('mkdirp / mkdirp', () => { let TEST_DIR @@ -29,7 +25,7 @@ describe('mkdirp / mkdirp', () => { const file = path.join(TEST_DIR, x, y, z) - fse.mkdirp(file, o755, err => { + fse.mkdirp(file, 0o755, err => { assert.ifError(err) fse.pathExists(file, (err, ex) => { assert.ifError(err) @@ -38,9 +34,9 @@ describe('mkdirp / mkdirp', () => { assert.ifError(err) if (os.platform().indexOf('win') === 0) { - assert.strictEqual(stat.mode & o777, o666) + assert.strictEqual(stat.mode & 0o777, 0o666) } else { - assert.strictEqual(stat.mode & o777, o755) + assert.strictEqual(stat.mode & 0o777, 0o755) } assert.ok(stat.isDirectory(), 'target not a directory') diff --git a/lib/mkdirs/__tests__/perm.test.js b/lib/mkdirs/__tests__/perm.test.js index 8aa0743b..b883a652 100644 --- a/lib/mkdirs/__tests__/perm.test.js +++ b/lib/mkdirs/__tests__/perm.test.js @@ -8,10 +8,6 @@ const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -const o755 = parseInt('755', 8) -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) - describe('mkdirp / perm', () => { let TEST_DIR @@ -25,7 +21,7 @@ describe('mkdirp / perm', () => { it('async perm', done => { const file = path.join(TEST_DIR, (Math.random() * (1 << 30)).toString(16)) - fse.mkdirp(file, o755, err => { + fse.mkdirp(file, 0o755, err => { assert.ifError(err) fse.pathExists(file, (err, ex) => { assert.ifError(err) @@ -34,9 +30,9 @@ describe('mkdirp / perm', () => { assert.ifError(err) if (os.platform().indexOf('win') === 0) { - assert.strictEqual(stat.mode & o777, o666) + assert.strictEqual(stat.mode & 0o777, 0o666) } else { - assert.strictEqual(stat.mode & o777, o755) + assert.strictEqual(stat.mode & 0o777, 0o755) } assert.ok(stat.isDirectory(), 'target not a directory') @@ -47,7 +43,7 @@ describe('mkdirp / perm', () => { }) it('async root perm', done => { - fse.mkdirp(path.join(os.tmpdir(), 'tmp'), o755, err => { + fse.mkdirp(path.join(os.tmpdir(), 'tmp'), 0o755, err => { assert.ifError(err) done() }) diff --git a/lib/mkdirs/__tests__/perm_sync.test.js b/lib/mkdirs/__tests__/perm_sync.test.js index 27b475e8..2c75967c 100644 --- a/lib/mkdirs/__tests__/perm_sync.test.js +++ b/lib/mkdirs/__tests__/perm_sync.test.js @@ -8,10 +8,6 @@ const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -const o755 = parseInt('755', 8) -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) - describe('mkdirp / perm_sync', () => { let TEST_DIR @@ -25,7 +21,7 @@ describe('mkdirp / perm_sync', () => { it('sync perm', done => { const file = path.join(TEST_DIR, (Math.random() * (1 << 30)).toString(16) + '.json') - fse.mkdirpSync(file, o755) + fse.mkdirpSync(file, 0o755) fse.pathExists(file, (err, ex) => { assert.ifError(err) assert.ok(ex, 'file created') @@ -33,9 +29,9 @@ describe('mkdirp / perm_sync', () => { assert.ifError(err) if (os.platform().indexOf('win') === 0) { - assert.strictEqual(stat.mode & o777, o666) + assert.strictEqual(stat.mode & 0o777, 0o666) } else { - assert.strictEqual(stat.mode & o777, o755) + assert.strictEqual(stat.mode & 0o777, 0o755) } assert.ok(stat.isDirectory(), 'target not a directory') @@ -46,7 +42,7 @@ describe('mkdirp / perm_sync', () => { it('sync root perm', done => { const file = TEST_DIR - fse.mkdirpSync(file, o755) + fse.mkdirpSync(file, 0o755) fse.pathExists(file, (err, ex) => { assert.ifError(err) assert.ok(ex, 'file created') diff --git a/lib/mkdirs/__tests__/race.test.js b/lib/mkdirs/__tests__/race.test.js index 611d10fc..1d075f46 100644 --- a/lib/mkdirs/__tests__/race.test.js +++ b/lib/mkdirs/__tests__/race.test.js @@ -8,10 +8,6 @@ const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -const o755 = parseInt('755', 8) -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) - describe('mkdirp / race', () => { let TEST_DIR let file @@ -42,7 +38,7 @@ describe('mkdirp / race', () => { mk(file, () => --res === 0 ? done() : undefined) function mk (file, callback) { - fse.mkdirp(file, o755, err => { + fse.mkdirp(file, 0o755, err => { assert.ifError(err) fse.pathExists(file, (err, ex) => { assert.ifError(err) @@ -51,9 +47,9 @@ describe('mkdirp / race', () => { assert.ifError(err) if (os.platform().indexOf('win') === 0) { - assert.strictEqual(stat.mode & o777, o666) + assert.strictEqual(stat.mode & 0o777, 0o666) } else { - assert.strictEqual(stat.mode & o777, o755) + assert.strictEqual(stat.mode & 0o777, 0o755) } assert.ok(stat.isDirectory(), 'target not a directory') diff --git a/lib/mkdirs/__tests__/rel.test.js b/lib/mkdirs/__tests__/rel.test.js index 837e1e6b..bb00031e 100644 --- a/lib/mkdirs/__tests__/rel.test.js +++ b/lib/mkdirs/__tests__/rel.test.js @@ -10,10 +10,6 @@ const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -const o755 = parseInt('755', 8) -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) - describe('mkdirp / relative', () => { let TEST_DIR let file @@ -39,7 +35,7 @@ describe('mkdirp / relative', () => { it('should make the directory with relative path', done => { process.chdir(TEST_DIR) - fse.mkdirp(file, o755, err => { + fse.mkdirp(file, 0o755, err => { assert.ifError(err) fse.pathExists(file, (err, ex) => { assert.ifError(err) @@ -50,9 +46,9 @@ describe('mkdirp / relative', () => { process.chdir(CWD) if (os.platform().indexOf('win') === 0) { - assert.strictEqual(stat.mode & o777, o666) + assert.strictEqual(stat.mode & 0o777, 0o666) } else { - assert.strictEqual(stat.mode & o777, o755) + assert.strictEqual(stat.mode & 0o777, 0o755) } assert.ok(stat.isDirectory(), 'target not a directory') diff --git a/lib/mkdirs/__tests__/root.test.js b/lib/mkdirs/__tests__/root.test.js index ee49c39d..2d0974de 100644 --- a/lib/mkdirs/__tests__/root.test.js +++ b/lib/mkdirs/__tests__/root.test.js @@ -7,8 +7,6 @@ const assert = require('assert') /* global describe, it */ -const o755 = parseInt('755', 8) - describe('mkdirp / root', () => { // '/' on unix, 'c:/' on windows. const dir = path.normalize(path.resolve(path.sep)).toLowerCase() @@ -17,7 +15,7 @@ describe('mkdirp / root', () => { if (process.platform === 'win32' && (dir.indexOf('c:\\') === -1) && (dir.indexOf('d:\\') === -1)) return it('should', done => { - fse.mkdirp(dir, o755, err => { + fse.mkdirp(dir, 0o755, err => { if (err) throw err fs.stat(dir, (er, stat) => { if (er) throw er diff --git a/lib/mkdirs/__tests__/sync.test.js b/lib/mkdirs/__tests__/sync.test.js index 0652333a..1b7fe092 100644 --- a/lib/mkdirs/__tests__/sync.test.js +++ b/lib/mkdirs/__tests__/sync.test.js @@ -8,10 +8,6 @@ const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -const o755 = parseInt('755', 8) -const o777 = parseInt('777', 8) -const o666 = parseInt('666', 8) - describe('mkdirp / sync', () => { let TEST_DIR let file @@ -35,7 +31,7 @@ describe('mkdirp / sync', () => { it('should', done => { try { - fse.mkdirpSync(file, o755) + fse.mkdirpSync(file, 0o755) } catch (err) { assert.fail(err) } @@ -47,9 +43,9 @@ describe('mkdirp / sync', () => { assert.ifError(err) // http://stackoverflow.com/questions/592448/c-how-to-set-file-permissions-cross-platform if (os.platform().indexOf('win') === 0) { - assert.strictEqual(stat.mode & o777, o666) + assert.strictEqual(stat.mode & 0o777, 0o666) } else { - assert.strictEqual(stat.mode & o777, o755) + assert.strictEqual(stat.mode & 0o777, 0o755) } assert.ok(stat.isDirectory(), 'target not a directory') diff --git a/lib/mkdirs/__tests__/umask.test.js b/lib/mkdirs/__tests__/umask.test.js index 6049dccc..e911dbc5 100644 --- a/lib/mkdirs/__tests__/umask.test.js +++ b/lib/mkdirs/__tests__/umask.test.js @@ -8,8 +8,6 @@ const fse = require('../../') /* global afterEach, beforeEach, describe, it */ -const o777 = parseInt('777', 8) - describe('mkdirp', () => { let TEST_DIR let _rndDir @@ -47,7 +45,7 @@ describe('mkdirp', () => { assert.ok(ex, 'file created') fs.stat(_rndDir, (err, stat) => { assert.ifError(err) - assert.strictEqual(stat.mode & o777, o777 & (~process.umask())) + assert.strictEqual(stat.mode & 0o777, 0o777 & (~process.umask())) assert.ok(stat.isDirectory(), 'target not a directory') done() }) @@ -71,7 +69,7 @@ describe('mkdirp', () => { assert.ok(ex, 'file created') fs.stat(_rndDir, (err, stat) => { assert.ifError(err) - assert.strictEqual(stat.mode & o777, (o777 & (~process.umask()))) + assert.strictEqual(stat.mode & 0o777, (0o777 & (~process.umask()))) assert.ok(stat.isDirectory(), 'target not a directory') done() }) diff --git a/lib/mkdirs/mkdirs-sync.js b/lib/mkdirs/mkdirs-sync.js index a34acb99..25d794e2 100644 --- a/lib/mkdirs/mkdirs-sync.js +++ b/lib/mkdirs/mkdirs-sync.js @@ -4,8 +4,6 @@ const fs = require('graceful-fs') const path = require('path') const invalidWin32Path = require('./win32').invalidWin32Path -const o777 = parseInt('0777', 8) - function mkdirsSync (p, opts, made) { if (!opts || typeof opts !== 'object') { opts = { mode: opts } @@ -21,7 +19,7 @@ function mkdirsSync (p, opts, made) { } if (mode === undefined) { - mode = o777 & (~process.umask()) + mode = 0o777 & (~process.umask()) } if (!made) made = null diff --git a/lib/mkdirs/mkdirs.js b/lib/mkdirs/mkdirs.js index 18975337..9c72dc91 100644 --- a/lib/mkdirs/mkdirs.js +++ b/lib/mkdirs/mkdirs.js @@ -4,8 +4,6 @@ const fs = require('graceful-fs') const path = require('path') const invalidWin32Path = require('./win32').invalidWin32Path -const o777 = parseInt('0777', 8) - function mkdirs (p, opts, callback, made) { if (typeof opts === 'function') { callback = opts @@ -24,7 +22,7 @@ function mkdirs (p, opts, callback, made) { const xfs = opts.fs || fs if (mode === undefined) { - mode = o777 & (~process.umask()) + mode = 0o777 & (~process.umask()) } if (!made) made = null