{"id":41952311,"url":"https://github.com/risan/write-to-file","last_synced_at":"2026-01-25T21:34:39.202Z","repository":{"id":57399827,"uuid":"159558880","full_name":"risan/write-to-file","owner":"risan","description":"Writes data to file and automatically create its directories if not exists.","archived":false,"fork":false,"pushed_at":"2018-12-07T05:46:00.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-19T21:47:54.608Z","etag":null,"topics":["fs","mkdirp","write-file"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/risan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-28T20:11:19.000Z","updated_at":"2018-12-07T05:46:55.000Z","dependencies_parsed_at":"2022-09-26T17:01:17.782Z","dependency_job_id":null,"html_url":"https://github.com/risan/write-to-file","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/risan/write-to-file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fwrite-to-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fwrite-to-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fwrite-to-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fwrite-to-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/risan","download_url":"https://codeload.github.com/risan/write-to-file/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fwrite-to-file/sbom","scorecard":{"id":777181,"data":{"date":"2025-08-11","repo":{"name":"github.com/risan/write-to-file","commit":"a890f8755dbf7771eae5934410ea09ba3c095ded"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-23T03:54:24.622Z","repository_id":57399827,"created_at":"2025-08-23T03:54:24.622Z","updated_at":"2025-08-23T03:54:24.622Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28759413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T20:56:06.009Z","status":"ssl_error","status_checked_at":"2026-01-25T20:54:48.203Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fs","mkdirp","write-file"],"created_at":"2026-01-25T21:34:38.527Z","updated_at":"2026-01-25T21:34:39.196Z","avatar_url":"https://github.com/risan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Write to File\n\n[![Build Status](https://badgen.net/travis/risan/write-to-file)](https://travis-ci.org/risan/write-to-file)\n[![Test Covarage](https://badgen.net/codecov/c/github/risan/write-to-file)](https://codecov.io/gh/risan/write-to-file)\n[![Greenkeeper](https://badges.greenkeeper.io/risan/write-to-file.svg)](https://greenkeeper.io)\n[![Latest Version](https://badgen.net/npm/v/write-to-file)](https://www.npmjs.com/package/write-to-file)\n\nWrites data to file and automatically create its directories if not exists.\n\n## Installation\n\n```bash\n$ npm install write-to-file\n```\n\n## Usage\n\n```js\nconst writeToFile = require(\"write-to-file\");\n\n(async () =\u003e {\n  try {\n    await writeToFile(\"foo/bar/baz.txt\", \"Hello World!\");\n  } catch(error) {\n    console.error(error.message);\n  }\n})();\n```\n\nIf `foo/bar` directory does not exist, it will be created automatically.\n\n## Recipes\n\n### Set the Character Encoding\n\nYou can pass the character encoding as the third argument. Default to `utf8`.\n\n```js\nconst writeToFile = require(\"write-to-file\");\n\n(async () =\u003e {\n  const buff = Buffer.from(\"Hello World!\");\n\n  try {\n    await writeToFile(\"foo.txt\", buff.toString(\"hex\"), \"hex\");\n  } catch(error) {\n    console.error(error.message);\n  }\n})();\n```\n\nYou can also pass an object:\n\n```js\nwriteToFile(\"foo.txt\", buff.toString(\"hex\"), {\n  encoding: \"hex\"\n});\n```\n\n### Appending Data to a File\n\nBy default, if the file already exists, it will be overwritten. For appending data to a file, you may pass the `flag` option:\n\n```js\nconst writeToFile = require(\"write-to-file\");\n\n(async () =\u003e {\n  try {\n    await writeToFile(\"foo.txt\", \"bar\", {\n      flag: \"a\"\n    });\n  } catch(error) {\n    console.error(error.message);\n  }\n})();\n```\n\n## API\n\n```js\nwriteToFile(file, data, [options])\n```\n\n### Parameters\n\n* `file` (`String`): The file path to write to.\n* `data` (`String`|`Buffer`): Data to write.\n* `options` (Optional `Object`|`String`): You may pass the encoding as the third argument. You may also pass an object:\n    * `encoding` (`String`): The character encoding to use, default to `utf8`.\n    * `mode` (`Number`): The file permission to set, default to `0o666`.\n    * `flag` (`String`): The [file system](https://nodejs.org/dist/latest-v11.x/docs/api/fs.html#fs_file_system_flags) flag, default to `w`.\n    * `createDirMode` (`Number`): The directory permission to set when creating the parent directory that does not exist, default to `0o777`.\n\n### Returns\n\nIt returns a `Promise` which when resolved contains a `true` value.\n\n## Related\n\n* [create-dir](https://github.com/risan/create-dir): Module to create directory recursively.\n\n## License\n\n[MIT](https://github.com/risan/write-to-file/blob/master/LICENSE) © [Risan Bagja Pradana](https://bagja.net)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisan%2Fwrite-to-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frisan%2Fwrite-to-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisan%2Fwrite-to-file/lists"}