{"action":"created","issue":{"url":"https://api.github.com/repos/jprichardson/node-fs-extra/issues/194","labels_url":"https://api.github.com/repos/jprichardson/node-fs-extra/issues/194/labels{/name}","comments_url":"https://api.github.com/repos/jprichardson/node-fs-extra/issues/194/comments","events_url":"https://api.github.com/repos/jprichardson/node-fs-extra/issues/194/events","html_url":"https://github.com/jprichardson/node-fs-extra/pull/194","id":117818645,"number":194,"title":"allow ensureFile(Sync) to provide data to be written to created file","user":{"login":"tonylukasavage","id":594112,"avatar_url":"https://avatars.githubusercontent.com/u/594112?v=3","gravatar_id":"","url":"https://api.github.com/users/tonylukasavage","html_url":"https://github.com/tonylukasavage","followers_url":"https://api.github.com/users/tonylukasavage/followers","following_url":"https://api.github.com/users/tonylukasavage/following{/other_user}","gists_url":"https://api.github.com/users/tonylukasavage/gists{/gist_id}","starred_url":"https://api.github.com/users/tonylukasavage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonylukasavage/subscriptions","organizations_url":"https://api.github.com/users/tonylukasavage/orgs","repos_url":"https://api.github.com/users/tonylukasavage/repos","events_url":"https://api.github.com/users/tonylukasavage/events{/privacy}","received_events_url":"https://api.github.com/users/tonylukasavage/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-19T13:57:42Z","updated_at":"2015-11-19T14:26:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jprichardson/node-fs-extra/pulls/194","html_url":"https://github.com/jprichardson/node-fs-extra/pull/194","diff_url":"https://github.com/jprichardson/node-fs-extra/pull/194.diff","patch_url":"https://github.com/jprichardson/node-fs-extra/pull/194.patch"},"body":"> This PR includes tests and docs for a backwards compatible change to the API.\r\n\r\nEssentially I've changed the signature of `ensureFile(file, callback)` to `ensureFile(file, [data], callback)`, adding an optional `data` parameter that can be used to populate a created file. I use fs-extra frequently and find myself needing this functionality fairly often. For example, if I want to make sure an JSON configuration file exists, and if not put bare minimum valid JSON in it, I might use this new version of the API like this:\r\n\r\n```js\r\nfse.ensureFile('file.json', '{}', function(err) {\r\n    // do stuff...\r\n});\r\n```\r\n\r\nThe change is modeled along the same lines as node.js's `fs.writeFile()` API. At this time it does not _complete_ that API, meaning this PR does not attempt to additionally add the optional `options` parameter that is available in `fs.writeFile()`. Having said that, if adding that aspect would make this PR more acceptable, I'd be happy to implement that as well, making `ensureFile()` and near mirror of the `fs.writeFile()` API."},"comment":{"url":"https://api.github.com/repos/jprichardson/node-fs-extra/issues/comments/158072482","html_url":"https://github.com/jprichardson/node-fs-extra/pull/194#issuecomment-158072482","issue_url":"https://api.github.com/repos/jprichardson/node-fs-extra/issues/194","id":158072482,"user":{"login":"tonylukasavage","id":594112,"avatar_url":"https://avatars.githubusercontent.com/u/594112?v=3","gravatar_id":"","url":"https://api.github.com/users/tonylukasavage","html_url":"https://github.com/tonylukasavage","followers_url":"https://api.github.com/users/tonylukasavage/followers","following_url":"https://api.github.com/users/tonylukasavage/following{/other_user}","gists_url":"https://api.github.com/users/tonylukasavage/gists{/gist_id}","starred_url":"https://api.github.com/users/tonylukasavage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonylukasavage/subscriptions","organizations_url":"https://api.github.com/users/tonylukasavage/orgs","repos_url":"https://api.github.com/users/tonylukasavage/repos","events_url":"https://api.github.com/users/tonylukasavage/events{/privacy}","received_events_url":"https://api.github.com/users/tonylukasavage/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T14:26:45Z","updated_at":"2015-11-19T14:26:45Z","body":"Looks like the appveyor setup has an issue with the `nodejs=2.3` configuration... all other tests are passing and it doesn't appear to be related to this PR directly."}}