Skip to content

Commit 5e663d6

Browse files
Kudosindresorhus
andauthoredMay 24, 2021
Add newInstance option for macOS (#253)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 0347d3b commit 5e663d6

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed
 

‎index.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ declare namespace open {
2222
*/
2323
readonly background?: boolean;
2424

25+
/**
26+
__macOS only__
27+
28+
Open a new instance of the app even it's already running.
29+
30+
A new instance is always opened on other platforms.
31+
32+
@default false
33+
*/
34+
readonly newInstance?: boolean;
35+
2536
/**
2637
Specify the `name` of the app to open the `target` with and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
2738

‎index.js

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const open = async (target, options) => {
7777
options = {
7878
wait: false,
7979
background: false,
80+
newInstance: false,
8081
allowNonzeroExitCode: false,
8182
...options
8283
};
@@ -115,6 +116,10 @@ const open = async (target, options) => {
115116
cliArguments.push('--background');
116117
}
117118

119+
if (options.newInstance) {
120+
cliArguments.push('--new');
121+
}
122+
118123
if (app) {
119124
cliArguments.push('-a', app);
120125
}

‎readme.md

+9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ Default: `false`
8080

8181
Do not bring the app to the foreground.
8282

83+
##### newInstance <sup>(macOS only)</sup>
84+
85+
Type: `boolean`\
86+
Default: `false`
87+
88+
Open a new instance of the app even it's already running.
89+
90+
A new instance is always opened on other platforms.
91+
8392
##### app
8493

8594
Type: `{name: string | string[], arguments?: string[]} | Array<{name: string | string[], arguments: string[]}>`

0 commit comments

Comments
 (0)
Please sign in to comment.