Skip to content

Commit 0b288ec

Browse files
committedSep 4, 2019
use .resolve instead of .join
update readme
1 parent 7feaaf6 commit 0b288ec

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed
 

‎.verb.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ See [CHANGELOG.md].
6060
[wsoptions]: https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options
6161
[writefile]: https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
6262
[writefilesync]: https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options
63-
[writable]: https://nodejs.org/api/stream.html#stream_class_stream_writable
63+
[writable]: https://nodejs.org/api/stream.html#stream_class_stream_writable

‎README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# write [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/write.svg?style=flat)](https://www.npmjs.com/package/write) [![NPM monthly downloads](https://img.shields.io/npm/dm/write.svg?style=flat)](https://npmjs.org/package/write) [![NPM total downloads](https://img.shields.io/npm/dt/write.svg?style=flat)](https://npmjs.org/package/write) [![Build Status](https://travis-ci.org/jonschlinkert/write.svg?branch=master)](https://travis-ci.org/jonschlinkert/write)
1+
# write [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/write.svg?style=flat)](https://www.npmjs.com/package/write) [![NPM monthly downloads](https://img.shields.io/npm/dm/write.svg?style=flat)](https://npmjs.org/package/write) [![NPM total downloads](https://img.shields.io/npm/dt/write.svg?style=flat)](https://npmjs.org/package/write) [![Build Status](https://travis-ci.org/jonschlinkert/write.svg?branch=2.0)](https://travis-ci.org/jonschlinkert/write)
22

33
> Write data to a file, replacing the file if it already exists and creating any intermediate directories if they don't already exist. Thin wrapper around node's native fs methods.
44
@@ -61,7 +61,7 @@ write.sync('foo.txt', 'some data...', { increment: true });
6161

6262
## API
6363

64-
### [write](index.js#L39)
64+
### [write](index.js#L40)
6565

6666
Asynchronously writes data to a file, replacing the file if it already exists and creating any intermediate directories if they don't already exist. Data can be a string or a buffer. Returns a promise if a callback function is not passed.
6767

@@ -71,6 +71,7 @@ Asynchronously writes data to a file, replacing the file if it already exists an
7171
* `data` **{String|Buffer|Uint8Array}**: Data to write.
7272
* `options` **{Object}**: Options to pass to [fs.writeFile](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback)
7373
* `callback` **{Function}**: (optional) If no callback is provided, a promise is returned.
74+
* `returns` **{Object}**: Returns an object with the `path` and `contents` of the file that was written to the file system. This is useful for debugging when `options.increment` is used and the path might have been modified.
7475

7576
**Example**
7677

@@ -94,7 +95,7 @@ write('foo.txt', 'This is content...', err => {
9495
});
9596
```
9697

97-
### [.sync](index.js#L86)
98+
### [.sync](index.js#L87)
9899

99100
The synchronous version of [write](#write). Returns undefined.
100101

@@ -103,7 +104,7 @@ The synchronous version of [write](#write). Returns undefined.
103104
* `filepath` **{String}**: file path.
104105
* `data` **{String|Buffer|Uint8Array}**: Data to write.
105106
* `options` **{Object}**: Options to pass to [fs.writeFileSync](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)
106-
* `returns` **{undefined}**
107+
* `returns` **{Object}**: Returns an object with the `path` and `contents` of the file that was written to the file system. This is useful for debugging when `options.increment` is used and the path might have been modified.
107108

108109
**Example**
109110

@@ -112,7 +113,7 @@ const write = require('write');
112113
write.sync('foo.txt', 'This is content...');
113114
```
114115

115-
### [.stream](index.js#L125)
116+
### [.stream](index.js#L126)
116117

117118
Returns a new [WriteStream](https://nodejs.org/api/fs.html#fs_class_fs_writestream) object. Uses `fs.createWriteStream` to write data to a file, replacing the file if it already exists and creating any intermediate directories if they don't already exist. Data can be a string or a buffer.
118119

@@ -186,7 +187,7 @@ You might also be interested in these projects:
186187

187188
| **Commits** | **Contributor** |
188189
| --- | --- |
189-
| 41 | [jonschlinkert](https://github.com/jonschlinkert) |
190+
| 42 | [jonschlinkert](https://github.com/jonschlinkert) |
190191
| 2 | [jpetitcolas](https://github.com/jpetitcolas) |
191192
| 1 | [tunnckoCore](https://github.com/tunnckoCore) |
192193

@@ -205,4 +206,4 @@ Released under the [MIT License](LICENSE).
205206

206207
***
207208

208-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on August 12, 2019._
209+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on September 04, 2019._

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const incrementName = destpath => {
151151

152152
while (prev !== file.path && fs.existsSync(file.path)) {
153153
prev = file.path;
154-
file.path = path.join(file.dir, `${name} (${++n})${file.ext}`);
154+
file.path = path.resolve(file.dir, `${name} (${++n})${file.ext}`);
155155
}
156156

157157
return file.path;

0 commit comments

Comments
 (0)
Please sign in to comment.