-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from jonschlinkert/2.0
2.0 - refactor
- Loading branch information
Showing
13 changed files
with
552 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
# http://editorconfig.org/ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[{**/{actual,fixtures,expected,templates}/**,*.md}] | ||
[*.md] | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
# Enforce Unix newlines | ||
* text eol=lf | ||
|
||
# binaries | ||
*.ai binary | ||
*.psd binary | ||
*.jpg binary | ||
*.gif binary | ||
*.png binary | ||
*.jpeg binary | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,63 @@ | ||
## Usage | ||
|
||
```js | ||
var writeFile = require('write'); | ||
const write = require('write'); | ||
``` | ||
|
||
## API | ||
{%= apidocs("index.js") %} | ||
## Options | ||
|
||
## Release history | ||
The following options may be used with any method. | ||
|
||
### options.newline | ||
|
||
### v1.0.2 - 2017-07-11 | ||
**Type**: `boolean` | ||
|
||
- improved documentation | ||
**Default**: `undefined` | ||
|
||
### v1.0.0 - 2017-07-09 | ||
Ensure that contents has a trailing newline before writing it to the file system. | ||
|
||
```js | ||
write.sync('foo.txt', 'some data...', { newline: true }); | ||
``` | ||
|
||
**Added** | ||
|
||
- [promise support](#promise) | ||
### options.overwrite | ||
|
||
**Type**: `boolean` | ||
|
||
**Default**: `undefined` | ||
|
||
Set to `false` to prevent existing files from being overwritten. See [increment](#optionsincrement) for a less severe alternative. | ||
|
||
```js | ||
write.sync('foo.txt', 'some data...', { overwrite: false }); | ||
``` | ||
|
||
**Changed** | ||
### options.increment | ||
|
||
- The main export will now return a promise if no callback is passed | ||
**Type**: `boolean` | ||
|
||
**Default**: `undefined` | ||
|
||
Set to `true` to automatically rename files by appending an increment, like `foo (2).txt`, to prevent `foo.txt` from being overwritten. This is useful when writing log files, or other information where the file name is less important than the contents being written. | ||
|
||
```js | ||
write.sync('foo.txt', 'some data...', { increment: true }); | ||
// if "foo.txt" exists, the file will be renamed to "foo (2).txt" | ||
``` | ||
|
||
## API | ||
{%= apidocs("index.js") %} | ||
|
||
## Release history | ||
|
||
See [CHANGELOG.md]. | ||
|
||
|
||
[fs]: https://nodejs.org/api/fs.html | ||
|
||
[writestream]: https://nodejs.org/api/fs.html#fs_class_fs_writestream | ||
[wsoptions]: https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options | ||
[writefile]: https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback | ||
[writefilesync]: https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options | ||
[writable]: https://nodejs.org/api/stream.html#stream_class_stream_writable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Changelog | ||
|
||
### v2.0.0 - 2019-08-12 | ||
|
||
**Changes** | ||
|
||
- Refactored code | ||
- Use `fs.createWriteStream` in the main function to improve performance. | ||
|
||
**Added** | ||
|
||
- Added `overwrite` option | ||
- Added `increment` option | ||
|
||
See the [README](readme.md) for more details. | ||
|
||
**Removed** | ||
|
||
- Removed support for passing a custom string on `options.newline`. This should be done before passing the contents to `write()` | ||
- The `.promise` method was removed since _the main export returns a promise, making the method unnecessary_. | ||
|
||
|
||
### v1.0.2 - 2017-07-11 | ||
|
||
- improved documentation | ||
|
||
### v1.0.0 - 2017-07-09 | ||
|
||
**Added** | ||
|
||
- promise support | ||
|
||
**Changed** | ||
|
||
- The main export will now return a promise if no callback is passed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.