Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify to follow the rules of the new 'standard' and 'standard-markdown' #624

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ fs.copy('/tmp/mydir', '/tmp/mynewdir', err => {

// With Promises:
fs.copy('/tmp/myfile', '/tmp/mynewfile')
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example () {
Expand Down
12 changes: 6 additions & 6 deletions docs/emptyDir.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ fs.emptyDir('/tmp/some/dir', err => {

// With Promises:
fs.emptyDir('/tmp/some/dir')
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example () {
Expand Down
24 changes: 12 additions & 12 deletions docs/ensureDir.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ fs.ensureDir(dir, desiredMode, err => {

// With Promises:
fs.ensureDir(dir)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With Promises and a mode integer:
fs.ensureDir(dir, desiredMode)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (directory) {
Expand Down
12 changes: 6 additions & 6 deletions docs/ensureFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ fs.ensureFile(file, err => {

// With Promises:
fs.ensureFile(file)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (f) {
Expand Down
12 changes: 6 additions & 6 deletions docs/ensureLink.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ fs.ensureLink(srcpath, dstpath, err => {

// With Promises:
fs.ensureLink(srcpath, dstpath)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (src, dest) {
Expand Down
12 changes: 6 additions & 6 deletions docs/ensureSymlink.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ fs.ensureSymlink(srcpath, dstpath, err => {

// With Promises:
fs.ensureSymlink(srcpath, dstpath)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (src, dest) {
Expand Down
12 changes: 6 additions & 6 deletions docs/move.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ fs.move(srcpath, dstpath, err => {

// With Promises:
fs.move(srcpath, dstpath)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (src, dest) {
Expand Down
14 changes: 7 additions & 7 deletions docs/outputFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ fs.outputFile(file, 'hello!', err => {

// With Promises:
fs.outputFile(file, 'hello!')
.then(() => fs.readFile(file, 'utf8'))
.then(data => {
console.log(data) // => hello!
})
.catch(err => {
console.error(err)
})
.then(() => fs.readFile(file, 'utf8'))
.then(data => {
console.log(data) // => hello!
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (f) {
Expand Down
2 changes: 1 addition & 1 deletion docs/outputJson-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Almost the same as [`writeJsonSync`](writeJson-sync.md), except that if the dire
const fs = require('fs-extra')

const file = '/tmp/this/path/does/not/exist/file.json'
fs.outputJsonSync(file, {name: 'JP'})
fs.outputJsonSync(file, { name: 'JP' })

const data = fs.readJsonSync(file)
console.log(data.name) // => JP
Expand Down
20 changes: 10 additions & 10 deletions docs/outputJson.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const fs = require('fs-extra')
const file = '/tmp/this/path/does/not/exist/file.json'

// With a callback:
fs.outputJson(file, {name: 'JP'}, err => {
fs.outputJson(file, { name: 'JP' }, err => {
console.log(err) // => null

fs.readJson(file, (err, data) => {
Expand All @@ -31,19 +31,19 @@ fs.outputJson(file, {name: 'JP'}, err => {
})

// With Promises:
fs.outputJson(file, {name: 'JP'})
.then(() => fs.readJson(file))
.then(data => {
console.log(data.name) // => JP
})
.catch(err => {
console.error(err)
})
fs.outputJson(file, { name: 'JP' })
.then(() => fs.readJson(file))
.then(data => {
console.log(data.name) // => JP
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (f) {
try {
await fs.outputJson(f, {name: 'JP'})
await fs.outputJson(f, { name: 'JP' })

const data = await fs.readJson(f)

Expand Down
24 changes: 12 additions & 12 deletions docs/readJson.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ fs.readJson('./package.json', (err, packageObj) => {

// With Promises:
fs.readJson('./package.json')
.then(packageObj => {
console.log(packageObj.version) // => 0.1.3
})
.catch(err => {
console.error(err)
})
.then(packageObj => {
console.log(packageObj.version) // => 0.1.3
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example () {
Expand Down Expand Up @@ -64,12 +64,12 @@ fs.readJson(file, { throws: false }, (err, obj) => {

// Wtih Promises:
fs.readJson(file, { throws: false })
.then(obj => {
console.log(obj) // => null
})
.catch(err => {
console.error(err) // Not called
})
.then(obj => {
console.log(obj) // => null
})
.catch(err => {
console.error(err) // Not called
})

// With async/await:
async function example (f) {
Expand Down
12 changes: 6 additions & 6 deletions docs/remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ fs.remove('/home/jprichardson', err => {

// With Promises:
fs.remove('/tmp/myfile')
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (src, dest) {
Expand Down
2 changes: 1 addition & 1 deletion docs/writeJson-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Writes an object to a JSON file.
```js
const fs = require('fs-extra')

fs.writeJsonSync('./package.json', {name: 'fs-extra'})
fs.writeJsonSync('./package.json', { name: 'fs-extra' })
```
---

Expand Down
18 changes: 9 additions & 9 deletions docs/writeJson.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ Writes an object to a JSON file.
const fs = require('fs-extra')

// With a callback:
fs.writeJson('./package.json', {name: 'fs-extra'}, err => {
fs.writeJson('./package.json', { name: 'fs-extra' }, err => {
if (err) return console.error(err)

console.log('success!')
})

// With Promises:
fs.writeJson('./package.json', {name: 'fs-extra'})
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})
fs.writeJson('./package.json', { name: 'fs-extra' })
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example () {
try {
await fs.writeJson('./package.json', {name: 'fs-extra'})
await fs.writeJson('./package.json', { name: 'fs-extra' })
console.log('success!')
} catch (err) {
console.error(err)
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/promise.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('promise support', () => {
it('provides fse.promises API', () => {
const desc = Object.getOwnPropertyDescriptor(fse, 'promises')
assert.ok(desc)
assert.equal(typeof desc.get, 'function')
assert.strict.equal(typeof desc.get, 'function')
})
}
})
2 changes: 1 addition & 1 deletion lib/copy-sync/__tests__/broken-symlink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('copy-sync / broken symlink', () => {
})

it('should throw an error when dereference=true', () => {
assert.throws(() => copySync(src, out, {dereference: true}), err => err.code === 'ENOENT')
assert.throws(() => copySync(src, out, { dereference: true }), err => err.code === 'ENOENT')
})
})

Expand Down
14 changes: 7 additions & 7 deletions lib/copy-sync/__tests__/copy-sync-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ describe('+ copySync() / file', () => {
describe('> when destination file does NOT exist', () => {
describe('> when overwrite is true', () => {
it('should copy the file and not throw an error', () => {
fs.copySync(src, dest, {overwrite: true})
fs.copySync(src, dest, { overwrite: true })
const destData = fs.readFileSync(dest, 'utf8')
assert.strictEqual(srcData, destData)
})
})

describe('> when overwrite is false', () => {
it('should copy the file and not throw an error', () => {
fs.copySync(src, dest, {overwrite: false})
fs.copySync(src, dest, { overwrite: false })
const destData = fs.readFileSync(dest, 'utf8')
assert.strictEqual(srcData, destData)
})
Expand All @@ -161,22 +161,22 @@ describe('+ copySync() / file', () => {

describe('> when overwrite is true', () => {
it('should copy the file and not throw an error', () => {
fs.copySync(src, dest, {overwrite: true})
fs.copySync(src, dest, { overwrite: true })
destData = fs.readFileSync(dest, 'utf8')
assert.strictEqual(srcData, destData)
})
})

describe('> when overwrite is false', () => {
it('should not throw an error', () => {
fs.copySync(src, dest, {overwrite: false})
fs.copySync(src, dest, { overwrite: false })

// copy never happened
const destDataNew = fs.readFileSync(dest, 'utf8')
assert.strictEqual(destData, destDataNew)
})
it('should throw an error when errorOnExist is true', () => {
assert.throws(() => fs.copySync(src, dest, {overwrite: false, errorOnExist: true}))
assert.throws(() => fs.copySync(src, dest, { overwrite: false, errorOnExist: true }))

// copy never happened
const destDataNew = fs.readFileSync(dest, 'utf8')
Expand All @@ -188,7 +188,7 @@ describe('+ copySync() / file', () => {
it('should copy the file and not throw an error', () => {
try {
fs.chmodSync(dest, parseInt('444', 8))
fs.copySync(src, dest, {overwrite: true})
fs.copySync(src, dest, { overwrite: true })
destData = fs.readFileSync(dest, 'utf8')
assert.strictEqual(srcData, destData)
} finally {
Expand All @@ -212,7 +212,7 @@ describe('+ copySync() / file', () => {
})

it('is an alias for overwrite', () => {
fs.copySync(src, dest, {clobber: false})
fs.copySync(src, dest, { clobber: false })

// copy never happened
const destDataNew = fs.readFileSync(dest, 'utf8')
Expand Down
Loading