{"id":15678066,"url":"https://github.com/doowb/detect-file","last_synced_at":"2025-04-19T11:57:33.013Z","repository":{"id":57211998,"uuid":"62752024","full_name":"doowb/detect-file","owner":"doowb","description":"Uses a breadth-first search, when necessary, to resolve the file path using the correct casing, and verify that the file actually exists. Returns consistent results regardless of case sensitivity of the file path and/or operating system.","archived":false,"fork":false,"pushed_at":"2017-09-01T20:26:14.000Z","size":21,"stargazers_count":12,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T12:59:42.185Z","etag":null,"topics":["case-insensitive","detect-file-exists","file","file-exists","filepath","find-files","fs"],"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/doowb.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":"2016-07-06T20:43:07.000Z","updated_at":"2021-10-03T16:30:52.000Z","dependencies_parsed_at":"2022-09-09T10:51:45.008Z","dependency_job_id":null,"html_url":"https://github.com/doowb/detect-file","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fdetect-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fdetect-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fdetect-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fdetect-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doowb","download_url":"https://codeload.github.com/doowb/detect-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246155984,"owners_count":20732355,"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","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":["case-insensitive","detect-file-exists","file","file-exists","filepath","find-files","fs"],"created_at":"2024-10-03T16:16:00.118Z","updated_at":"2025-03-30T21:31:47.810Z","avatar_url":"https://github.com/doowb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# detect-file [![NPM version](https://img.shields.io/npm/v/detect-file.svg?style=flat)](https://www.npmjs.com/package/detect-file) [![NPM monthly downloads](https://img.shields.io/npm/dm/detect-file.svg?style=flat)](https://npmjs.org/package/detect-file)  [![NPM total downloads](https://img.shields.io/npm/dt/detect-file.svg?style=flat)](https://npmjs.org/package/detect-file) [![Linux Build Status](https://img.shields.io/travis/doowb/detect-file.svg?style=flat\u0026label=Travis)](https://travis-ci.org/doowb/detect-file) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/detect-file.svg?style=flat\u0026label=AppVeyor)](https://ci.appveyor.com/project/doowb/detect-file)\n\n\u003e Detects if a file exists and returns the resolved filepath.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save detect-file\n```\n\nInstall with [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add detect-file\n```\n\n## Usage\n\n```js\nvar detect = require('detect-file');\n```\n\n## API\n\n### [detect](index.js#L33)\n\nDetect the given `filepath` if it exists.\n\n**Params**\n\n* `filepath` **{String}**: filepath to detect.\n* `options` **{Object}**: Additional options.\n* `options.nocase` **{Boolean}**: Set this to `true` to force case-insensitive filename checks. This is useful on case sensitive file systems.\n* `returns` **{String}**: Returns the detected filepath if it exists, otherwise returns `null`.\n\n**Example**\n\n```js\nvar res = detect('package.json');\nconsole.log(res);\n//=\u003e \"package.json\"\n\nvar res = detect('fake-file.json');\nconsole.log(res)\n//=\u003e null\n```\n\n## Case sensitive file systems\n\nWhen using the `nocase` option, this library will attempt to detect the filepath with the following methods:\n\n1. Try to read all files in the `filepath` using `fs.readdirSync`. If successful and `filepath` is a directory, return the `filepath`.\n2. Try to read all files in the `filepath`'s directory using `fs.readdirSync`. If successful, do case insensitive comparasions of the `filepath` to the files in `filepath`'s directory.\n\n## About\n\n### Related projects\n\n[fs-exists-sync](https://www.npmjs.com/package/fs-exists-sync): Drop-in replacement for `fs.existsSync` with zero dependencies. Other libs I found either have crucial differences… [more](https://github.com/jonschlinkert/fs-exists-sync) | [homepage](https://github.com/jonschlinkert/fs-exists-sync \"Drop-in replacement for `fs.existsSync` with zero dependencies. Other libs I found either have crucial differences from fs.existsSync, or unnecessary dependencies. See README.md for more info.\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Brian Woodward**\n\n* [github/doowb](https://github.com/doowb)\n* [twitter/doowb](https://twitter.com/doowb)\n\n### License\n\nCopyright © 2017, [Brian Woodward](https://github.com/doowb).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 05, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fdetect-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoowb%2Fdetect-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fdetect-file/lists"}