Skip to content

Commit b0eb751

Browse files
manidlouRyanZim
andauthored
Improve docs (#795)
* improve docs * Update docs/ensureSymlink-sync.md Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> * Update docs/ensureSymlink.md Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> * add Error type to docs Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com>
1 parent a2738d3 commit b0eb751

24 files changed

+77
-72
lines changed

docs/copy-sync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# copySync(src, dest[, options])
22

3-
Copy a file or directory. The directory can have contents. Like `cp -r`.
3+
Copy a file or directory. The directory can have contents.
44

55
- `src` `<String>` Note that if `src` is a directory it will copy everything inside of this directory, not the entire directory itself (see [issue #537](https://github.com/jprichardson/node-fs-extra/issues/537)).
66
- `dest` `<String>` Note that if `src` is a file, `dest` cannot be a directory (see [issue #323](https://github.com/jprichardson/node-fs-extra/issues/323)).

docs/copy.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# copy(src, dest[, options][, callback])
22

3-
Copy a file or directory. The directory can have contents. Like `cp -r`.
3+
Copy a file or directory. The directory can have contents.
44

55
- `src` `<String>` Note that if `src` is a directory it will copy everything inside of this directory, not the entire directory itself (see [issue #537](https://github.com/jprichardson/node-fs-extra/issues/537)).
66
- `dest` `<String>` Note that if `src` is a file, `dest` cannot be a directory (see [issue #323](https://github.com/jprichardson/node-fs-extra/issues/323)).
@@ -11,6 +11,7 @@ Copy a file or directory. The directory can have contents. Like `cp -r`.
1111
- `preserveTimestamps` `<boolean>`: When true, will set last modification and access times to the ones of the original source files. When false, timestamp behavior is OS-dependent. Default is `false`.
1212
- `filter` `<Function>`: Function to filter copied files. Return `true` to include, `false` to exclude. Can also return a `Promise` that resolves to `true` or `false` (or pass in an `async` function).
1313
- `callback` `<Function>`
14+
- `err` `<Error>`
1415

1516
## Example:
1617

@@ -20,13 +21,11 @@ const fs = require('fs-extra')
2021
// With a callback:
2122
fs.copy('/tmp/myfile', '/tmp/mynewfile', err => {
2223
if (err) return console.error(err)
23-
2424
console.log('success!')
2525
}) // copies file
2626

2727
fs.copy('/tmp/mydir', '/tmp/mynewdir', err => {
2828
if (err) return console.error(err)
29-
3029
console.log('success!')
3130
}) // copies directory, even if it has subdirectories or files
3231

@@ -64,7 +63,6 @@ const filterFunc = (src, dest) => {
6463

6564
fs.copy('/tmp/mydir', '/tmp/mynewdir', { filter: filterFunc }, err => {
6665
if (err) return console.error(err)
67-
6866
console.log('success!')
6967
})
7068
```

docs/emptyDir.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Ensures that a directory is empty. Deletes directory contents if the directory i
66

77
- `dir` `<String>`
88
- `callback` `<Function>`
9+
- `err` `<Error>`
910

1011
## Example:
1112

@@ -16,7 +17,6 @@ const fs = require('fs-extra')
1617
// With a callback:
1718
fs.emptyDir('/tmp/some/dir', err => {
1819
if (err) return console.error(err)
19-
2020
console.log('success!')
2121
})
2222

docs/ensureDir-sync.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# ensureDirSync(dir[,options])
22

3-
Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`. If provided, options may specify the desired mode for the directory.
3+
Ensures that the directory exists. If the directory structure does not exist, it is created. If provided, options may specify the desired mode for the directory.
44

55
**Aliases:** `mkdirsSync()`, `mkdirpSync()`
66

77
- `dir` `<String>`
88
- `options` `<Integer>|<Object>`
9+
- If it is `Integer`, it will be `mode`.
10+
- If it is `Object`, it will be `{ mode: <Integer> }`.
11+
912
## Example:
1013

1114
```js

docs/ensureDir.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# ensureDir(dir[,options][,callback])
22

3-
Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`.
3+
Ensures that the directory exists. If the directory structure does not exist, it is created.
44

55
**Aliases:** `mkdirs()`, `mkdirp()`
66

77
- `dir` `<String>`
88
- `options` `<Integer>|<Object>`
9+
- If it is `Integer`, it will be `mode`.
10+
- If it is `Object`, it will be `{ mode: <Integer> }`.
911
- `callback` `<Function>`
12+
- `err` `<Error>`
1013

1114
## Example:
1215

docs/ensureFile.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Ensures that the file exists. If the file that is requested to be created is in
66

77
- `file` `<String>`
88
- `callback` `<Function>`
9+
- `err` `<Error>`
910

1011
## Example:
1112

docs/ensureLink-sync.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# ensureLinkSync(srcpath, dstpath)
1+
# ensureLinkSync(srcPath, destPath)
22

33
Ensures that the link exists. If the directory structure does not exist, it is created.
44

55
**Alias:** `createLinkSync()`
66

7-
- `srcpath` `<String>`
8-
- `dstpath` `<String>`
7+
- `srcPath` `<String>`
8+
- `destPath` `<String>`
99

1010
## Example:
1111

1212
```js
1313
const fs = require('fs-extra')
1414

15-
const srcpath = '/tmp/file.txt'
16-
const dstpath = '/tmp/this/path/does/not/exist/file.txt'
17-
fs.ensureLinkSync(srcpath, dstpath)
15+
const srcPath = '/tmp/file.txt'
16+
const destPath = '/tmp/this/path/does/not/exist/file.txt'
17+
fs.ensureLinkSync(srcPath, destPath)
1818
// link has now been created, including the directory it is to be placed in
1919
```

docs/ensureLink.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
# ensureLink(srcpath, dstpath[, callback])
1+
# ensureLink(srcPath, destPath[, callback])
22

33
Ensures that the link exists. If the directory structure does not exist, it is created.
44

55
**Alias:** `createLink()`
66

7-
- `srcpath` `<String>`
8-
- `dstpath` `<String>`
7+
- `srcPath` `<String>`
8+
- `destPath` `<String>`
99
- `callback` `<Function>`
10+
- `err` `<Error>`
1011

1112
## Example:
1213

1314
```js
1415
const fs = require('fs-extra')
1516

16-
const srcpath = '/tmp/file.txt'
17-
const dstpath = '/tmp/this/path/does/not/exist/file.txt'
17+
const srcPath = '/tmp/file.txt'
18+
const destPath = '/tmp/this/path/does/not/exist/file.txt'
1819

1920
// With a callback:
20-
fs.ensureLink(srcpath, dstpath, err => {
21+
fs.ensureLink(srcPath, destPath, err => {
2122
console.log(err) // => null
2223
// link has now been created, including the directory it is to be placed in
2324
})
2425

2526
// With Promises:
26-
fs.ensureLink(srcpath, dstpath)
27+
fs.ensureLink(srcPath, destPath)
2728
.then(() => {
2829
console.log('success!')
2930
})
@@ -41,5 +42,5 @@ async function example (src, dest) {
4142
}
4243
}
4344

44-
example(srcpath, dstpath)
45+
example(srcPath, destPath)
4546
```

docs/ensureSymlink-sync.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# ensureSymlinkSync(srcpath, dstpath[, type])
1+
# ensureSymlinkSync(srcPath, destPath[, type])
22

33
Ensures that the symlink exists. If the directory structure does not exist, it is created.
44

55
**Alias:** `createSymlinkSync()`
66

7-
- `srcpath` `<String>`
8-
- `dstpath` `<String>`
9-
- `type` `<String>`
7+
- `srcPath` `<String>`
8+
- `destPath` `<String>`
9+
- `type` `<String>` It is only available on Windows and ignored on other platforms. It can be set to `dir`, `file`, or `junction`.
1010

1111
## Example:
1212

1313
```js
1414
const fs = require('fs-extra')
1515

16-
const srcpath = '/tmp/file.txt'
17-
const dstpath = '/tmp/this/path/does/not/exist/file.txt'
18-
fs.ensureSymlinkSync(srcpath, dstpath)
16+
const srcPath = '/tmp/file.txt'
17+
const destPath = '/tmp/this/path/does/not/exist/file.txt'
18+
fs.ensureSymlinkSync(srcPath, destPath)
1919
// symlink has now been created, including the directory it is to be placed in
2020
```

docs/ensureSymlink.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
# ensureSymlink(srcpath, dstpath[, type][, callback])
1+
# ensureSymlink(srcPath, destPath[, type][, callback])
22

33
Ensures that the symlink exists. If the directory structure does not exist, it is created.
44

55
**Alias:** `createSymlink()`
66

7-
- `srcpath` `<String>`
8-
- `dstpath` `<String>`
9-
- `type` `<String>`
7+
- `srcPath` `<String>`
8+
- `destPath` `<String>`
9+
- `type` `<String>` It is only available on Windows and ignored on other platforms. It can be set to `dir`, `file`, or `junction`.
1010
- `callback` `<Function>`
11+
- `err` `<Error>`
1112

1213
## Example:
1314

1415
```js
1516
const fs = require('fs-extra')
1617

17-
const srcpath = '/tmp/file.txt'
18-
const dstpath = '/tmp/this/path/does/not/exist/file.txt'
18+
const srcPath = '/tmp/file.txt'
19+
const destPath = '/tmp/this/path/does/not/exist/file.txt'
1920

2021
// With a callback:
21-
fs.ensureSymlink(srcpath, dstpath, err => {
22+
fs.ensureSymlink(srcPath, destPath, err => {
2223
console.log(err) // => null
2324
// symlink has now been created, including the directory it is to be placed in
2425
})
2526

2627
// With Promises:
27-
fs.ensureSymlink(srcpath, dstpath)
28+
fs.ensureSymlink(srcPath, destPath)
2829
.then(() => {
2930
console.log('success!')
3031
})
@@ -42,5 +43,5 @@ async function example (src, dest) {
4243
}
4344
}
4445

45-
example(srcpath, dstpath)
46+
example(srcPath, destPath)
4647
```

0 commit comments

Comments
 (0)