{"id":21074811,"url":"https://github.com/dawsbot/if-file-read","last_synced_at":"2025-10-26T18:09:21.226Z","repository":{"id":57271429,"uuid":"79544901","full_name":"dawsbot/if-file-read","owner":"dawsbot","description":"Read the first valid file in an array","archived":false,"fork":false,"pushed_at":"2022-06-14T21:05:39.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-22T17:47:54.459Z","etag":null,"topics":["filesystem","read"],"latest_commit_sha":null,"homepage":null,"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/dawsbot.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":"2017-01-20T09:22:15.000Z","updated_at":"2023-09-28T10:38:42.000Z","dependencies_parsed_at":"2022-09-01T00:42:41.372Z","dependency_job_id":null,"html_url":"https://github.com/dawsbot/if-file-read","commit_stats":null,"previous_names":["dawsonbotsford/if-file-read"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dawsbot/if-file-read","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fif-file-read","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fif-file-read/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fif-file-read/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fif-file-read/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawsbot","download_url":"https://codeload.github.com/dawsbot/if-file-read/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Fif-file-read/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272424347,"owners_count":24932893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["filesystem","read"],"created_at":"2024-11-19T19:18:10.176Z","updated_at":"2025-10-26T18:09:16.191Z","avatar_url":"https://github.com/dawsbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# if-file-read\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![XO code style][xo-image]][xo-url]\n\n\u003e Return the content of the first file in array which exists\n\n## Install\n\n```\nnpm install --save if-file-read\n```\n\n## Usage\n\n```js\nconst ifFileRead = require('if-file-read');\n\n// Where c.txt is the only file:\nifFileRead(['a.txt', 'b.txt', 'c.txt']);\n//=\u003e 'contents of c.txt file'\n\n// Where src/c.txt is the only file\nifFileRead(['a.txt', 'b.txt', 'c.txt'], {prepend: 'src'});\n//=\u003e 'contents of src/c.txt file'\n```\n\n## API\n\n### ifFileRead(files, options)\n\nReturns a `readFileSync` for the first valid file\n\n#### Arguments\n\n| Name    | Description                     |   Type   |  Default  |\n| ------- | ------------------------------- | -------- |  -------  |\n| files   | Array of file paths             | `array`  | arg required |\n|options.prepend| string to prepend to each file| `string`  |''    |\n\n#### Returns\n\nType: `string`\n\nThrows `Error` `\"No files found\"` if none of the files exist\n\n## License\n\nMIT © [Dawson Botsford](http://dawsonbotsford.com)\n\n[npm-image]: https://badge.fury.io/js/if-file-read.svg\n[npm-url]: https://npmjs.org/package/if-file-read\n[travis-image]: https://travis-ci.org/dawsbot/if-file-read.svg?branch=master\n[travis-url]: https://travis-ci.org/dawsbot/if-file-read\n[xo-image]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg\n[xo-url]: https://github.com/sindresorhus/xo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Fif-file-read","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawsbot%2Fif-file-read","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Fif-file-read/lists"}