Socket
Socket
Sign inDemoInstall

write

Package Overview
Dependencies
2
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

23

index.js

@@ -71,1 +71,24 @@ /*!

};
/**
* Uses `fs.createWriteStream`, but also creates any intermediate
* directories if they don't already exist.
*
* ```js
* var write = require('write');
* write.stream('foo.txt');
* ```
*
* @name writeFile.stream
* @param {String} `dest` Destination file path
* @return {Stream} Returns a write stream.
* @api public
*/
module.exports.stream = function writeFileStream(dest) {
var dir = path.dirname(dest);
if (!fs.existsSync(dir)) {
mkdir.sync(dir);
}
return fs.createWriteStream(dest);
};

27

package.json
{
"name": "write",
"description": "Write files to disk, creating intermediate directories if they don't exist.",
"version": "0.2.0",
"version": "0.2.1",
"homepage": "https://github.com/jonschlinkert/write",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/write.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/write",
"bugs": {
"url": "https://github.com/jonschlinkert/write/issues"
},
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/write/blob/master/LICENSE"
},
"license": "MIT",
"files": [

@@ -32,9 +23,9 @@ "index.js"

"dependencies": {
"mkdirp": "^0.5.0"
"mkdirp": "^0.5.1"
},
"devDependencies": {
"async": "^0.9.0",
"delete": "^0.1.5",
"mocha": "^2.2.1",
"should": "^5.2.0"
"async": "^1.4.0",
"delete": "^0.2.1",
"mocha": "^2.2.5",
"should": "^7.0.2"
},

@@ -41,0 +32,0 @@ "keywords": [

@@ -1,20 +0,25 @@

# write [![NPM version](https://badge.fury.io/js/write.svg)](http://badge.fury.io/js/write) [![Build Status](https://travis-ci.org/jonschlinkert/write.svg)](https://travis-ci.org/jonschlinkert/write)
# write [![NPM version](https://badge.fury.io/js/write.svg)](http://badge.fury.io/js/write) [![Build Status](https://travis-ci.org/jonschlinkert/write.svg)](https://travis-ci.org/jonschlinkert/write)
> Write files to disk, creating intermediate directories if they don't exist.
## Install with [npm](npmjs.org)
Install with [npm](https://www.npmjs.com/)
```bash
npm i write --save
```sh
$ npm i write --save
```
## API docs
### [.writeFile](./index.js#L32)
### [writeFile](index.js#L32)
Asynchronously write a file to disk. Creates any intermediate directories if they don't already exist.
* `dest` **{String}**: Destination file path
* `str` **{String}**: String to write to disk.
* `callback` **{Function}**
**Params**
* `dest` **{String}**: Destination file path
* `str` **{String}**: String to write to disk.
* `callback` **{Function}**
**Example**
```js

@@ -27,9 +32,13 @@ var writeFile = require('write');

### [.writeFile.sync](./index.js#L64)
### [.writeFile.sync](index.js#L64)
Synchronously write files to disk. Creates any intermediate directories if they don't already exist.
* `dest` **{String}**: Destination file path
* `str` **{String}**: String to write to disk.
**Params**
* `dest` **{String}**: Destination file path
* `str` **{String}**: String to write to disk.
**Example**
```js

@@ -40,34 +49,55 @@ var writeFile = require('write');

### [.writeFile.stream](index.js#L87)
Uses `fs.createWriteStream`, but also creates any intermediate directories if they don't already exist.
**Params**
* `dest` **{String}**: Destination file path
* `returns` **{Stream}**: Returns a write stream.
**Example**
```js
var write = require('write');
write.stream('foo.txt');
```
## Related
* [delete](https://github.com/jonschlinkert/delete): Delete files and folders and any intermediate directories if they exist (sync and async).
* [write-yaml](https://github.com/jonschlinkert/write-yaml): Write YAML. Converts JSON to YAML writes it to the specified file.
* [write-json](https://github.com/jonschlinkert/write-json): Write a JSON to file disk, also creates directories in the dest path if they don't already exist.
* [read-yaml](https://github.com/jonschlinkert/read-yaml): Very thin wrapper around js-yaml for directly reading in YAML files.
* [read-json](https://github.com/azer/read-json): Reads and parses a JSON file.
* [read-data](https://github.com/jonschlinkert/read-data): Read JSON or YAML files.
* [write-yaml](https://github.com/jonschlinkert/write-yaml): Write YAML. Converts JSON to YAML writes it to the specified file.
* [write-json](https://github.com/jonschlinkert/write-json): Write a JSON to file disk, also creates directories in the dest path if they… [more](https://github.com/jonschlinkert/write-json)
## Running tests
Install dev dependencies.
```bash
npm i -d && npm test
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/write/issues)
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/write/issues/new)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 07, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 29, 2015._
<!-- deps:mocha -->
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc