diff --git a/index.d.ts b/index.d.ts index 1be494b..8f3f237 100644 --- a/index.d.ts +++ b/index.d.ts @@ -22,6 +22,17 @@ declare namespace open { */ readonly background?: boolean; + /** + __macOS only__ + + Open a new instance of the app even it's already running. + + A new instance is always opened on other platforms. + + @default false + */ + readonly newInstance?: boolean; + /** 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. diff --git a/index.js b/index.js index 2bc2242..142b411 100644 --- a/index.js +++ b/index.js @@ -77,6 +77,7 @@ const open = async (target, options) => { options = { wait: false, background: false, + newInstance: false, allowNonzeroExitCode: false, ...options }; @@ -115,6 +116,10 @@ const open = async (target, options) => { cliArguments.push('--background'); } + if (options.newInstance) { + cliArguments.push('--new'); + } + if (app) { cliArguments.push('-a', app); } diff --git a/readme.md b/readme.md index 9a67dc8..4cf63e1 100644 --- a/readme.md +++ b/readme.md @@ -80,6 +80,15 @@ Default: `false` Do not bring the app to the foreground. +##### newInstance (macOS only) + +Type: `boolean`\ +Default: `false` + +Open a new instance of the app even it's already running. + +A new instance is always opened on other platforms. + ##### app Type: `{name: string | string[], arguments?: string[]} | Array<{name: string | string[], arguments: string[]}>`