Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skoshx/deno-open
Open is a package for opening URLs, files and executables with Deno. Inspired by sindresorhus' open.
https://github.com/skoshx/deno-open
Last synced: about 1 month ago
JSON representation
Open is a package for opening URLs, files and executables with Deno. Inspired by sindresorhus' open.
- Host: GitHub
- URL: https://github.com/skoshx/deno-open
- Owner: skoshx
- License: mit
- Created: 2020-03-11T16:55:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-18T09:42:26.000Z (about 1 month ago)
- Last Synced: 2024-11-18T10:55:38.620Z (about 1 month ago)
- Language: Shell
- Size: 40 KB
- Stars: 29
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# open for Deno
> open is a package for opening URLs, files and executables. Inspired by [open](https://github.com/sindresorhus/open)
## Features
- Really simple usage
- App arguments
- Includes `xdg-open` script###### Download
- [Normal](https://raw.githubusercontent.com/SkoshRG/deno-open/master/index.ts)
## Usage
```js
import { open } from 'https://deno.land/x/open/index.ts';// Opens the image in the default image viewer and waits for the opened app to quit.
await open('image.png', {wait: true});// Opens the URL in the default browser.
await open('https://google.com');// Opens the URL in a specified browser.
await open('https://google.com', {app: 'firefox'});// Specify app arguments.
await open('https://google.com', {app: ['google chrome', '--incognito']});
```> ⚠ Note: on Windows, if you have search parameters in your URL, you need need to wrap the `&` char in quote marks. See [#9](https://github.com/skoshx/deno-open/issues/9) ⚠
## API
It uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
### open(target, options?)
Returns a promise for the spawned Deno process.
### target: `string`
The URL, file or executable you want to open.
### options: `OpenOptions` (Optional)
#### wait: `boolean`
Waits for the spawned process to end, before resolving the Promise.
#### background: `boolean` (macOS only)
Opens the app in the background.
#### app: `string | string[]`
Specify the app you want to open the target with.
#### url: `boolean`
Encodes target with `encodeURI`. Useful for opening URLs.
> Note: on Windows, if you have search parameters in your URL, you need need to wrap the `&` char in quote marks. See [#9](https://github.com/skoshx/deno-open/issues/9)