Skip to content

Commit

Permalink
Make the wait option false by default
Browse files Browse the repository at this point in the history
Fixes #91
Fixes #92
  • Loading branch information
sindresorhus committed Mar 26, 2019
1 parent b30220c commit da2d663
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = async (target, options) => {
}

options = {
wait: true,
wait: false,
...options
};

Expand Down
23 changes: 11 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,24 @@ const open = require('opn');

// Opens the image in the default image viewer
(async () => {
await open('unicorn.png');

await open('unicorn.png', {wait: true});
console.log('The image viewer closed');
})();

// Opens the url in the default browser
open('http://sindresorhus.com');
// Opens the url in the default browser
await open('http://sindresorhus.com');

// Specify the app to open in
open('http://sindresorhus.com', {app: 'firefox'});
// Specify the app to open in
await open('http://sindresorhus.com', {app: 'firefox'});

// Specify app arguments
open('http://sindresorhus.com', {app: ['google chrome', '--incognito']});
// Specify app arguments
await open('http://sindresorhus.com', {app: ['google chrome', '--incognito']});
})();
```


## API

Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
It uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.

### opn(target, [options])

Expand All @@ -68,11 +67,11 @@ Type: `Object`
##### wait

Type: `boolean`<br>
Default: `true`
Default: `false`

Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.

On Windows you have to explicitly specify an app for it to be able to wait.
On Windows, you have to explicitly specify an app for it to be able to wait.

##### app

Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ test('open file in default app', async () => {
await open('index.js');
});

test('not wait for the app to close if wait: false', async () => {
await open('http://sindresorhus.com', {wait: false});
test('wait for the app to close if wait: true', async () => {
await open('http://sindresorhus.com', {wait: true});
});

test('open url in default app', async () => {
Expand Down

0 comments on commit da2d663

Please sign in to comment.