diff --git a/__tests__/commit.js b/__tests__/commit.js index afe3099..8c705ed 100644 --- a/__tests__/commit.js +++ b/__tests__/commit.js @@ -40,7 +40,7 @@ describe('#commit()', () => { let filter = through.obj(function (file, enc, cb) { called++; - file.contents = new Buffer('modified'); + file.contents = Buffer.from('modified'); this.push(file); cb(); }); diff --git a/__tests__/read.js b/__tests__/read.js index 38ba928..638cdf3 100644 --- a/__tests__/read.js +++ b/__tests__/read.js @@ -47,7 +47,7 @@ describe('#read()', () => { it('returns defaults as Buffer if file does not exist and defaults is provided', () => { const content = fs.read('file-who-does-not-exist.txt', { - defaults: new Buffer('foo\n'), + defaults: Buffer.from('foo\n'), raw: true }); expect(content).toBeInstanceOf(Buffer); diff --git a/__tests__/write.js b/__tests__/write.js index daa86e5..22723c8 100644 --- a/__tests__/write.js +++ b/__tests__/write.js @@ -23,7 +23,7 @@ describe('#write()', () => { it('write buffer to a new file', () => { const filepath = path.join(__dirname, 'fixtures/does-not-exist.txt'); - const contents = new Buffer('omg!', 'base64'); + const contents = Buffer.from('omg!', 'base64'); fs.write(filepath, contents); expect(fs.read(filepath)).toBe(contents.toString()); expect(fs.store.get(filepath).state).toBe('modified'); diff --git a/lib/util.js b/lib/util.js index bd9d92f..1072574 100644 --- a/lib/util.js +++ b/lib/util.js @@ -35,7 +35,8 @@ exports.globify = function (filePath) { if (glob.hasMagic(filePath)) { return filePath; - } else if (!fs.existsSync(filePath)) { + } + if (!fs.existsSync(filePath)) { // The target of a pattern who's not a glob and doesn't match an existing // entity on the disk is ambiguous. As such, match both files and directories. return [ @@ -47,7 +48,8 @@ exports.globify = function (filePath) { var fsStats = fs.statSync(filePath); if (fsStats.isFile()) { return filePath; - } else if (fsStats.isDirectory()) { + } + if (fsStats.isDirectory()) { return path.join(filePath, '**'); } throw new Error('Only file path or directory path are supported.'); diff --git a/package.json b/package.json index 1a07b4b..01f4a8b 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "coveralls": "^3.0.0", "escape-regexp": "0.0.1", "eslint": "^4.1.0", - "eslint-config-xo-space": "^0.17.0", + "eslint-config-xo-space": "^0.18.0", "jest": "^22.1.0", "mem-fs": "^1.0.0", "nsp": "^3.1.0",