{"id":15732554,"url":"https://github.com/jonschlinkert/open-finder-dialog","last_synced_at":"2025-09-21T01:13:05.069Z","repository":{"id":257805553,"uuid":"865428666","full_name":"jonschlinkert/open-finder-dialog","owner":"jonschlinkert","description":"Open a finder dialog window (finder prompt) programmatically.","archived":false,"fork":false,"pushed_at":"2025-06-08T16:57:20.000Z","size":19,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-08T03:46:36.925Z","etag":null,"topics":["darwin","dialog","file","file-manager","files","finder","mac","macos","manager","open","prompt","select"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","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/jonschlinkert.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"jonschlinkert"}},"created_at":"2024-09-30T14:13:11.000Z","updated_at":"2025-07-31T02:04:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"1c96dafa-e5d0-4fdc-8d19-e7c938759e58","html_url":"https://github.com/jonschlinkert/open-finder-dialog","commit_stats":null,"previous_names":["jonschlinkert/open-finder-dialog"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jonschlinkert/open-finder-dialog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fopen-finder-dialog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fopen-finder-dialog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fopen-finder-dialog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fopen-finder-dialog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/open-finder-dialog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fopen-finder-dialog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276180917,"owners_count":25598762,"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-09-20T02:00:10.207Z","response_time":63,"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":["darwin","dialog","file","file-manager","files","finder","mac","macos","manager","open","prompt","select"],"created_at":"2024-10-04T00:20:48.307Z","updated_at":"2025-09-21T01:13:05.058Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jonschlinkert"],"categories":["JavaScript"],"sub_categories":[],"readme":"# open-finder-dialog [![NPM version](https://img.shields.io/npm/v/open-finder-dialog.svg?style=flat)](https://www.npmjs.com/package/open-finder-dialog) [![NPM monthly downloads](https://img.shields.io/npm/dm/open-finder-dialog.svg?style=flat)](https://npmjs.org/package/open-finder-dialog) [![NPM total downloads](https://img.shields.io/npm/dt/open-finder-dialog.svg?style=flat)](https://npmjs.org/package/open-finder-dialog)\n\n\u003e Open a finder dialog window (finder prompt) programmatically. Only works on MacOS.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save open-finder-dialog\n```\n\n## Usage\n\n**Heads up!**: release v1.0.0 introduced breaking changes. Please see the [release history](#history) for details.\n\n```typescript\nimport { openFinderDialog } from 'open-finder-dialog';\n// or\nimport openFinderDialog from 'open-finder-dialog';\n\n// Open the dialog in the current working directory\nconst { files, canceled } = await openFinderDialog();\nconsole.log('Selected files:', files);\n// You can use the `canceled` property to determine if the user\n// canceled the dialog intentionally, so you can customize messaging\n// or logic accordingly.\n```\n\n## API\n\nSignature:\n\n```typescript\nexport const openFinderDialog = async (\n  initialDirectory?: string,\n  options?: {\n    filters?: string[];\n    limit?: number;\n    terminal?: string;\n  }\n): Promise\u003c{ files: string[]; canceled: boolean; }\u003e;\n```\n\n**Returns**\n\nA promise that resolves to an object:\n\n* `files`: an array of absolute POSIX file paths (as strings) that the user selected.\n* `canceled`: `true` if the user canceled the dialog, otherwise `false`.\n\n### Example usage\n\n```ts\n// Open the dialog in the current working directory\nconst { files, canceled } = await openFinderDialog();\nconsole.log('Selected files:', files);\n\nif (canceled) {\n  console.log('User canceled the dialog');\n}\n```\n\nExample with custom options:\n\n```ts\nconst { files } = await openFinderDialog('/Users/alex/Pictures', {\n  limit: 2,\n  filters: ['jpeg', 'png', 'json'],\n  terminal: 'iTerm'\n});\n\nconsole.log('Selected files:', files);\n```\n\nOpens a Finder dialog to select one or more files and returns the paths of selected files. Handles single and multiple selections, ensures correct focus return to the terminal, and uses macOS native dialogs.\n\n### Params\n\n**initialDirectory** (optional)\n\nThe initial directory where the dialog should open. Defaults to the current working directory.\n\n```ts\nconst output = await openFinderDialog('/some/directory');\n```\n\n**options** (optional)\n\nOptions for the file dialog:\n\n* **filters**: `string[]` — File UTI types or extensions to filter (e.g. [`public.jpeg`, `public.png`] or file extensions depending on macOS support).\n* **limit**: `number` — Maximum number of files that can be selected (minimum 1, default: 100).\n* **terminal**: `string` — Optionally specify your terminal app name, so focus returns to it after closing the dialog. If not set, [detect-terminal](https://www.npmjs.com/package/detect-terminal) is used.\n\n```ts\nconst output = await openFinderDialog(process.cwd(), {\n  filters: ['public.jpeg'],\n  limit: 1,\n  terminal: 'iTerm'\n});\n```\n\n**Notes about \"limit\"**\n\nIf you set a limit other than `1`, finder will not (cannot) prevent over-selection in the dialog. Meaning the user will potentially be able to select more than `limit` files. This is a limitation of the macOS Finder dialog, so the limit is enforced programmatically (by the applescript) after selection.\n\nAFAIK this is the only way it can be done, but I would love to have a better solution if someone wants to do a PR or open an issue to discuss.\n\n## History\n\n### v0.0.1\n\nInitial release\n\n### v0.0.2\n\nAdded support for specifying the terminal app.\n\n### v1.0.0\n\n* **BREAKING CHANGE**: Functions now return an object with `files` and `canceled` properties, instead of just the selected files.\n* Added `filters` and `limit` options.\n\n### v1.0.1\n\n* Upgrade [detect-terminal](https://github.com/jonschlinkert/detect-terminal) to v1.1.0\n\n## Related\n\nYou might also be interested in:\n\n* [open-file-manager-dialog](https://www.npmjs.com/package/open-file-manager-dialog): Cross-platform library for opening a file manager dialog window programmatically on MacOS, Windows, or Linux. | [homepage](https://github.com/jonschlinkert/open-file-manager-dialog \"Cross-platform library for opening a file manager dialog window programmatically on MacOS, Windows, or Linux.\")\n* [open-file-manager](https://www.npmjs.com/package/open-file-manager): Cross-platform utility to open a file or directory in the system's default file manager (Finder… [more](https://github.com/jonschlinkert/open-file-manager) | [homepage](https://github.com/jonschlinkert/open-file-manager \"Cross-platform utility to open a file or directory in the system's default file manager (Finder, Explorer, Nautilus, etc.)\")\n* [open-linux-file-dialog](https://www.npmjs.com/package/open-linux-file-dialog): Open a file dialog window programmatically to allow the user to select one or more… [more](https://github.com/jonschlinkert/open-linux-file-dialog) | [homepage](https://github.com/jonschlinkert/open-linux-file-dialog \"Open a file dialog window programmatically to allow the user to select one or more files. Only works on Linux. No dependencies. Supports zenity (GNOME), kdialog (KDE), yad (Yet Another Dialog), qarma (Qt-based), matedialog (MATE), rofi (window switcher wi\")\n* [open-windows-file-dialog](https://www.npmjs.com/package/open-windows-file-dialog): Programmatically open a file dialog window (explorer) for picking files. Only works on Windows. Also… [more](https://github.com/jonschlinkert/open-windows-file-dialog) | [homepage](https://github.com/jonschlinkert/open-windows-file-dialog \"Programmatically open a file dialog window (explorer) for picking files. Only works on Windows. Also see: open-finder-dialog, open-linux-file-dialog, and open-file-manager-dialog for other platforms.\")\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\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\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\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\u003c/details\u003e\n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2025, [Jon Schlinkert](https://github.com/jonschlinkert).\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.8.0, on May 25, 2025._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fopen-finder-dialog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fopen-finder-dialog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fopen-finder-dialog/lists"}