A Node.js package to find applications that can open a file on macOS
npm install open-with-applicationsopen-with-applications is a Node.js package designed to help you find applications that can open a given file on macOS. It leverages macOS's mdls and mdfind commands, as well as the CoreServices and CoreFoundation frameworks, to determine the appropriate apps that support a specific file type.
.app bundle-based applications.``bash`
npm install open-with-applications
`js
import { Mac } from 'open-with-applications';
const filePath = '/path/to/your/file.txt';
const applications = Mac.getApplications(filePath);
console.log(applications);
`
js
[
{
name: 'TextEdit',
path: '/Applications/TextEdit.app',
iconPath: '/Applications/TextEdit.app/Contents/Resources/TextEdit.icns',
},
{
name: 'Sublime Text',
path: '/Applications/Sublime Text.app',
iconPath: '/Applications/Sublime Text.app/Contents/Resources/Sublime Text.icns',
}
]
``