diff --git a/cli.js b/cli.js index 5e23302..9d182e0 100755 --- a/cli.js +++ b/cli.js @@ -1,19 +1,20 @@ #!/usr/bin/env node 'use strict'; const meow = require('meow'); -const opn = require('opn'); +const open = require('open'); const getStdin = require('get-stdin'); const tempWrite = require('temp-write'); const fileType = require('file-type'); const cli = meow(` Usage - $ opn [--wait] [-- [args]] - $ cat | opn [--wait] [--ext] [-- [args]] + $ opn [--wait] [--background] [-- [args]] + $ cat | opn [--ext] [--wait] [--background] [-- [args]] Options - --wait Wait for the app to exit - --ext File extension for when stdin file type can't be detected + --wait Wait for the app to exit + --background Do not bring the app to the foreground (macOS only) + --ext File extension for when stdin file type can't be detected Examples $ opn https://sindresorhus.com @@ -27,6 +28,13 @@ const cli = meow(` wait: { type: 'boolean', default: false + }, + background: { + type: 'boolean', + default: false + }, + ext: { + type: 'string' } } }); @@ -41,12 +49,12 @@ if (!input && process.stdin.isTTY) { } if (input) { - opn(input, cli.flags); + open(input, cli.flags); } else { (async () => { const stdin = await getStdin.buffer(); const type = fileType(stdin); const ext = cli.flags.ext || (type && type.ext) || 'txt'; - opn(tempWrite.sync(stdin, `opn.${ext}`), cli.flags); + open(tempWrite.sync(stdin, `opn.${ext}`), cli.flags); })(); } diff --git a/package.json b/package.json index 71326dc..b6df61d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "opn-cli", "version": "4.0.0", - "description": "A better node-open. Opens stuff like websites, files, executables. Cross-platform.", + "description": "Open stuff like URLs, files, executables. Cross-platform.", "license": "MIT", "repository": "sindresorhus/opn-cli", "author": { @@ -51,15 +51,15 @@ "file" ], "dependencies": { - "file-type": "^10.4.0", + "file-type": "^10.10.0", "get-stdin": "^6.0.0", "meow": "^5.0.0", - "opn": "^5.4.0", + "open": "^6.1.0", "temp-write": "^3.4.0" }, "devDependencies": { - "ava": "^0.25.0", + "ava": "^1.4.1", "execa": "^1.0.0", - "xo": "^0.23.0" + "xo": "^0.24.0" } } diff --git a/readme.md b/readme.md index d507f4b..e0c048d 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # opn-cli [![Build Status](https://travis-ci.org/sindresorhus/opn-cli.svg?branch=master)](https://travis-ci.org/sindresorhus/opn-cli) -> A better [node-open](https://github.com/pwnall/node-open). Opens stuff like websites, files, executables. Cross-platform. +> Open stuff like URLs, files, executables. Cross-platform. ## Install @@ -16,12 +16,13 @@ $ npm install --global opn-cli $ opn --help Usage - $ opn [--wait] [-- [args]] - $ cat | opn [--wait] [--ext] [-- [args]] + $ opn [--wait] [--background] [-- [args]] + $ cat | opn [--ext] [--wait] [--background] [-- [args]] Options - --wait Wait for the app to exit - --ext File extension for when stdin file type can't be detected + --wait Wait for the app to exit + --background Do not bring the app to the foreground (macOS only) + --ext File extension for when stdin file type can't be detected Examples $ opn https://sindresorhus.com @@ -37,7 +38,7 @@ The [following file types](https://github.com/sindresorhus/file-type#supported-f ## Related -- [opn](https://github.com/sindresorhus/opn) - API for this module +- [open](https://github.com/sindresorhus/open) - API for this module ## License