{"id":20758733,"url":"https://github.com/somewhatabstract/ancesdir","last_synced_at":"2025-04-30T04:35:03.129Z","repository":{"id":37800847,"uuid":"209094572","full_name":"somewhatabstract/ancesdir","owner":"somewhatabstract","description":"Find a specific ancestor/root directory given a starting location and a search parameter","archived":false,"fork":false,"pushed_at":"2025-04-19T14:55:58.000Z","size":6622,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T18:37:54.784Z","etag":null,"topics":["nodejs","nodejs-development","nodejs-modules","paths"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/somewhatabstract.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-09-17T15:46:13.000Z","updated_at":"2025-04-19T14:56:01.000Z","dependencies_parsed_at":"2023-10-02T18:35:57.639Z","dependency_job_id":"dc98e07d-3346-4831-a723-759e0cdeee86","html_url":"https://github.com/somewhatabstract/ancesdir","commit_stats":{"total_commits":1052,"total_committers":4,"mean_commits":263.0,"dds":0.5180608365019012,"last_synced_commit":"f2fc6bc9587aa9eb926acd30f9671a854293e65e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somewhatabstract%2Fancesdir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somewhatabstract%2Fancesdir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somewhatabstract%2Fancesdir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somewhatabstract%2Fancesdir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/somewhatabstract","download_url":"https://codeload.github.com/somewhatabstract/ancesdir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251644262,"owners_count":21620617,"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":["nodejs","nodejs-development","nodejs-modules","paths"],"created_at":"2024-11-17T09:53:27.773Z","updated_at":"2025-04-30T04:35:03.124Z","avatar_url":"https://github.com/somewhatabstract.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ancesdir\n\n[![Node CI](https://github.com/somewhatabstract/ancesdir/workflows/Node%20CI/badge.svg)](https://github.com/somewhatabstract/ancesdir/actions) [![codecov](https://codecov.io/gh/somewhatabstract/ancesdir/branch/main/graph/badge.svg)](https://codecov.io/gh/somewhatabstract/ancesdir) [![npm (tag)](https://img.shields.io/npm/v/ancesdir/latest)](https://www.npmjs.com/package/ancesdir) [![Node Version Required](https://img.shields.io/node/v/ancesdir/latest)](https://img.shields.io/node/v/ancesdir/latest)\n\nFind a specific ancestor/root directory given a starting location and a search parameter\n\nThere are a few packages out there that already support finding the root directory of a project based off assumptions like that directory containing `package.json` or `node_modules`. However, this is not always the case. I needed a way to find an ancestor directory that may not always have these markers. So, this provides the means to specify a custom marker file or directory as the means to identify the ancestor that you may need.\n\nThis may be useful in a variety of situations. For example, a monorepo where you want to differentiate in development scripts between the root folder of each package, and the root folder of the entire repository.\n\n## Getting Started\n\n### pnpm\n**`pnpm add ancesdir`**\n\n### yarn\n\n**`yarn add ancesdir`**\n\n### npm\n\n **`npm install ancesdir`**\n\n## Usage\n\n### Default\n\n```javascript\nimport ancesdir from \"ancesdir\";\n\nconsole.log(ancesdir());\n```\n\nOutputs the absolute path of the first parent directory to the `ancesdir` package that contains `package.json`.\n\nIn most cases, this is likely all you need.\n\n### From Specific Location\n\n```javascript\nimport ancesdir from \"ancesdir\";\n\nconsole.log(ancesdir(__dirname));\n```\n\nOutputs the absolute path of the first parent directory to `__dirname` that contains `package.json`.\n\n### Custom Target From Specific Location\n\n```javascript\nimport ancesdir from \"ancesdir\";\n\nconsole.log(ancesdir(__dirname, \".mymarkerfile\");\n```\n\nOutputs the absolute path of the first parent directory that contains a file or directory called `.mymarkerfile`.\n\nThis is useful if you don't have a classic file hierarchy or you want to use this for more advanced use cases where having control over the file system item that identifies your ancestor is useful.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomewhatabstract%2Fancesdir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomewhatabstract%2Fancesdir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomewhatabstract%2Fancesdir/lists"}