Skip to content

Commit 006fb4a

Browse files
Merge pull request #8 from jonschlinkert/2.0
2.0 - refactor
2 parents 4cd516f + 601522a commit 006fb4a

13 files changed

+552
-391
lines changed

Diff for: .editorconfig

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# http://editorconfig.org/
21
root = true
32

43
[*]
5-
charset = utf-8
6-
end_of_line = lf
7-
indent_size = 2
84
indent_style = space
9-
insert_final_newline = true
5+
indent_size = 2
6+
charset = utf-8
107
trim_trailing_whitespace = true
8+
insert_final_newline = true
119

12-
[{**/{actual,fixtures,expected,templates}/**,*.md}]
10+
[*.md]
1311
trim_trailing_whitespace = false
14-
insert_final_newline = false

Diff for: .eslintrc.json

+13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
{
2+
"extends": [
3+
"eslint:recommended"
4+
],
5+
26
"env": {
37
"browser": false,
48
"es6": true,
59
"node": true,
610
"mocha": true
711
},
812

13+
"parserOptions":{
14+
"ecmaVersion": 9,
15+
"sourceType": "module",
16+
"ecmaFeatures": {
17+
"modules": true,
18+
"experimentalObjectRestSpread": true
19+
}
20+
},
21+
922
"globals": {
1023
"document": false,
1124
"navigator": false,

Diff for: .gitattributes

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
# Enforce Unix newlines
2-
* text eol=lf
3-
4-
# binaries
5-
*.ai binary
6-
*.psd binary
7-
*.jpg binary
8-
*.gif binary
9-
*.png binary
10-
*.jpeg binary
1+
* text=auto

Diff for: .travis.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ sudo: false
22
os:
33
- linux
44
- osx
5+
- windows
56
language: node_js
67
node_js:
78
- node
8-
- '8'
9-
- '7'
10-
- '6'
11-
- '5'
12-
- '4'
9+
- '12'
10+
- '10'

Diff for: .verb.md

+47-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,63 @@
11
## Usage
22

33
```js
4-
var writeFile = require('write');
4+
const write = require('write');
55
```
66

7-
## API
8-
{%= apidocs("index.js") %}
7+
## Options
98

10-
## Release history
9+
The following options may be used with any method.
10+
11+
### options.newline
1112

12-
### v1.0.2 - 2017-07-11
13+
**Type**: `boolean`
1314

14-
- improved documentation
15+
**Default**: `undefined`
1516

16-
### v1.0.0 - 2017-07-09
17+
Ensure that contents has a trailing newline before writing it to the file system.
18+
19+
```js
20+
write.sync('foo.txt', 'some data...', { newline: true });
21+
```
1722

18-
**Added**
1923

20-
- [promise support](#promise)
24+
### options.overwrite
25+
26+
**Type**: `boolean`
27+
28+
**Default**: `undefined`
29+
30+
Set to `false` to prevent existing files from being overwritten. See [increment](#optionsincrement) for a less severe alternative.
31+
32+
```js
33+
write.sync('foo.txt', 'some data...', { overwrite: false });
34+
```
2135

22-
**Changed**
36+
### options.increment
2337

24-
- The main export will now return a promise if no callback is passed
38+
**Type**: `boolean`
39+
40+
**Default**: `undefined`
41+
42+
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.
43+
44+
```js
45+
write.sync('foo.txt', 'some data...', { increment: true });
46+
// if "foo.txt" exists, the file will be renamed to "foo (2).txt"
47+
```
48+
49+
## API
50+
{%= apidocs("index.js") %}
51+
52+
## Release history
53+
54+
See [CHANGELOG.md].
2555

2656

2757
[fs]: https://nodejs.org/api/fs.html
58+
59+
[writestream]: https://nodejs.org/api/fs.html#fs_class_fs_writestream
60+
[wsoptions]: https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options
61+
[writefile]: https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
62+
[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

Diff for: CHANGELOG.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
### v2.0.0 - 2019-08-12
4+
5+
**Changes**
6+
7+
- Refactored code
8+
- Use `fs.createWriteStream` in the main function to improve performance.
9+
10+
**Added**
11+
12+
- Added `overwrite` option
13+
- Added `increment` option
14+
15+
See the [README](readme.md) for more details.
16+
17+
**Removed**
18+
19+
- Removed support for passing a custom string on `options.newline`. This should be done before passing the contents to `write()`
20+
- The `.promise` method was removed since _the main export returns a promise, making the method unnecessary_.
21+
22+
23+
### v1.0.2 - 2017-07-11
24+
25+
- improved documentation
26+
27+
### v1.0.0 - 2017-07-09
28+
29+
**Added**
30+
31+
- promise support
32+
33+
**Changed**
34+
35+
- The main export will now return a promise if no callback is passed

Diff for: LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

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

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

0 commit comments

Comments
 (0)