Skip to content

Commit

Permalink
Merge pull request #8 from jonschlinkert/2.0
Browse files Browse the repository at this point in the history
2.0 - refactor
  • Loading branch information
jonschlinkert authored Sep 4, 2019
2 parents 4cd516f + 601522a commit 006fb4a
Show file tree
Hide file tree
Showing 13 changed files with 552 additions and 391 deletions.
11 changes: 4 additions & 7 deletions .editorconfig
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
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
{
"extends": [
"eslint:recommended"
],

"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": true
},

"parserOptions":{
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true
}
},

"globals": {
"document": false,
"navigator": false,
Expand Down
11 changes: 1 addition & 10 deletions .gitattributes
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
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ sudo: false
os:
- linux
- osx
- windows
language: node_js
node_js:
- node
- '8'
- '7'
- '6'
- '5'
- '4'
- '12'
- '10'
58 changes: 47 additions & 11 deletions .verb.md
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
35 changes: 35 additions & 0 deletions CHANGELOG.md
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
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2017, Jon Schlinkert.
Copyright (c) 2014-present, Jon Schlinkert.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
Loading

0 comments on commit 006fb4a

Please sign in to comment.