Socket
Socket
Sign inDemoInstall

write-file

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

write-file

Writing a file to disk, creates intermediate directories in the destination path if they dont already exist.


Version published
Maintainers
1
Weekly downloads
896
increased by13.99%

Weekly downloads

Readme

Source

write-file npmjs.com The MIT License npm downloads

Writing a file to disk, creates intermediate directories in the destination path if they dont already exist.

code climate standard code style travis build status coverage status dependency status

Install

Install with npm

$ npm i write-file --save

Usage

For more use-cases see the tests

const writeFile = require('write-file')

API

writeFile

Writes a file to disk with support for creating intermediate directories and JSON files.

Params

  • <fp> {String|Buffer|Number}: filepath to the new file
  • data {String|Buffer|Object}: if object, JSON.stringify and writes it
  • [options] {Object|String}: passed to mkdirp too; if string, treats it as opts.encoding
  • callback {Function}: done callback

Example

var writeFile = require('write-file')

writeFile('foo/bar/baz/qux.txt', 'some contents', function (err) {
  if (err) return console.log(err)
  console.log('file is written')
})

// automatically writes a json files
writeFile('foo/qux/bar.json', { foo: 'bar' }, function (err) {
  // if not `err`, file is written
})

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Keywords

FAQs

Last updated on 02 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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