source: trip-planner-front/node_modules/open/index.d.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.6 KB
Line 
1import {ChildProcess} from 'child_process';
2
3declare namespace open {
4 interface Options {
5 /**
6 Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
7
8 Note that it waits for the app to exit, not just for the window to close.
9
10 On Windows, you have to explicitly specify an app for it to be able to wait.
11
12 @default false
13 */
14 readonly wait?: boolean;
15
16 /**
17 __macOS only__
18
19 Do not bring the app to the foreground.
20
21 @default false
22 */
23 readonly background?: boolean;
24
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
36 /**
37 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.
38
39 The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use [`open.apps`](#openapps) which auto-detects the correct binary to use.
40
41 You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
42 */
43 readonly app?: App | readonly App[];
44
45 /**
46 Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
47
48 We do not recommend setting this option. The convention for success is exit code zero.
49
50 @default false
51 */
52 readonly allowNonzeroExitCode?: boolean;
53 }
54
55 type AppName =
56 | 'chrome'
57 | 'firefox'
58 | 'edge';
59
60 type App = {
61 name: string | readonly string[];
62 arguments?: readonly string[];
63 };
64}
65
66// eslint-disable-next-line no-redeclare
67declare const open: {
68 /**
69 Open stuff like URLs, files, executables. Cross-platform.
70
71 Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
72
73 There is a caveat for [double-quotes on Windows](https://github.com/sindresorhus/open#double-quotes-on-windows) where all double-quotes are stripped from the `target`.
74
75 @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
76 @returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
77
78 @example
79 ```
80 import open = require('open');
81
82 // Opens the image in the default image viewer
83 await open('unicorn.png', {wait: true});
84 console.log('The image viewer app closed');
85
86 // Opens the url in the default browser
87 await open('https://sindresorhus.com');
88
89 // Opens the URL in a specified browser.
90 await open('https://sindresorhus.com', {app: {name: 'firefox'}});
91
92 // Specify app arguments.
93 await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
94 ```
95 */
96 (
97 target: string,
98 options?: open.Options
99 ): Promise<ChildProcess>;
100
101 /**
102 An object containing auto-detected binary names for common apps. Useful to work around cross-platform differences.
103
104 @example
105 ```
106 import open = require('open');
107
108 await open('https://google.com', {
109 app: {
110 name: open.apps.chrome
111 }
112 });
113 ```
114 */
115 apps: Record<open.AppName, string | readonly string[]>;
116};
117
118export = open;
Note: See TracBrowser for help on using the repository browser.