open-resource
v1.0.2
Published
Cross-platform utility to open URLs or files with the system default application.
Maintainers
Readme
🪄 open-resource
A simple, cross-platform Node.js CLI and library to open URLs or files using the system’s default application — works on macOS, Windows, and Linux.
✨ Features
- 🧠 Automatically detects OS and runs the appropriate command (
open,start, orxdg-open) - 🌍 Opens URLs in your default browser
- 📄 Opens local files and directories with their associated apps
- ⚙️ Works both as a CLI and an importable module
- 🪶 Zero dependencies — lightweight, fast, and easy to use
🚀 Installation
Global (CLI)
npm install -g open-resourceLocal (Project)
npm install open-resource🧰 CLI Usage
open-resource <file-or-url>Examples:
# Open a website
open-resource https://www.salesforce.com
# Open a local PDF file
open-resource ./docs/report.pdf
# Open a directory
open-resource ./src🧩 Node.js API
import { openResource } from "open-resource";
openResource("https://google.com"); // Open a URL in default browser
openResource("./files/myfile.txt"); // Open a file in associated app
openResource("./images"); // Open folder in file explorer⚙️ How It Works
| Platform | Command Used | Example |
| -------- | ------------ | ------------------------------- |
| macOS | open | open "https://google.com" |
| Windows | start | start "" "https://google.com" |
| Linux | xdg-open | xdg-open "https://google.com" |
💻 Development Setup
git clone https://github.com/mchinnappan100/open-resource
cd open-resource
npm install
npm linkTest it locally:
open-resource https://www.salesforce.com📦 Publish to npm
npm login
npm publish --access public💡 Roadmap
- [ ] Add
--appflag to specify custom app (e.g., Chrome, VSCode) - [ ] Add
--waitflag to block until app closes - [ ] Add verbose logging option
- [ ] Support for WSL environments
⚖️ License
MIT © 2025 Mohan Chinnappan
