\begin{quote}
A better \href{https://github.com/pwnall/node-open}{\texttt{ node-\/open}}. Opens stuff like websites, files, executables. Cross-\/platform. \end{quote}
If need this for Electron, use \href{https://electronjs.org/docs/api/shell\#shellopenitemfullpath}{\texttt{ {\ttfamily shell.\+open\+Item()}}} instead.\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19113}{}\doxysubsubsection{Why?}\label{md_sfcode_node_modules_opn_readme_autotoc_md19113}

\begin{DoxyItemize}
\item Actively maintained
\item Supports app arguments
\item Safer as it uses {\ttfamily spawn} instead of {\ttfamily exec}
\item Fixes most of the open {\ttfamily node-\/open} issues
\item Includes the latest \href{http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=c55122295c2a480fa721a9614f0e2d42b2949c18}{\texttt{ {\ttfamily xdg-\/open} script}} for Linux
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19114}{}\doxysection{Install}\label{md_sfcode_node_modules_opn_readme_autotoc_md19114}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install opn }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19115}{}\doxysection{Usage}\label{md_sfcode_node_modules_opn_readme_autotoc_md19115}

\begin{DoxyCode}{0}
\DoxyCodeLine{const opn = require('opn');}
\DoxyCodeLine{}
\DoxyCodeLine{// Opens the image in the default image viewer}
\DoxyCodeLine{opn('unicorn.png').then(() => \{}
\DoxyCodeLine{    // image viewer closed}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{// Opens the url in the default browser}
\DoxyCodeLine{opn('http://sindresorhus.com');}
\DoxyCodeLine{}
\DoxyCodeLine{// Specify the app to open in}
\DoxyCodeLine{opn('http://sindresorhus.com', \{app: 'firefox'\});}
\DoxyCodeLine{}
\DoxyCodeLine{// Specify app arguments}
\DoxyCodeLine{opn('http://sindresorhus.com', \{app: ['google chrome', '-\/-\/incognito']\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19116}{}\doxysection{API}\label{md_sfcode_node_modules_opn_readme_autotoc_md19116}
Uses the command {\ttfamily open} on mac\+OS, {\ttfamily start} on Windows and {\ttfamily xdg-\/open} on other platforms.\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19117}{}\doxysubsection{opn(target, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_opn_readme_autotoc_md19117}
Returns a promise for the \href{https://nodejs.org/api/child_process.html\#child_process_class_childprocess}{\texttt{ spawned child process}}. You would normally not need to use this for anything, but it can be useful if you\textquotesingle{}d like to attach custom event listeners or perform other operations directly on the spawned process.\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19118}{}\doxysubsubsection{target}\label{md_sfcode_node_modules_opn_readme_autotoc_md19118}
Type\+: {\ttfamily string}

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 opens in your default browser.\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19119}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_opn_readme_autotoc_md19119}
Type\+: {\ttfamily Object}\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19120}{}\doxyparagraph{wait}\label{md_sfcode_node_modules_opn_readme_autotoc_md19120}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Wait for the opened app to exit before fulfilling the promise. If {\ttfamily false} it\textquotesingle{}s fulfilled immediately when opening the app.

On Windows you have to explicitly specify an app for it to be able to wait.\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19121}{}\doxyparagraph{app}\label{md_sfcode_node_modules_opn_readme_autotoc_md19121}
Type\+: {\ttfamily string} {\ttfamily Array}

Specify the app to open the {\ttfamily target} with, or an array with the app and app arguments.

The app name is platform dependent. Don\textquotesingle{}t hard code it in reusable modules. For example, Chrome is {\ttfamily google chrome} on mac\+OS, {\ttfamily google-\/chrome} on Linux and {\ttfamily chrome} on Windows.\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19122}{}\doxysection{Related}\label{md_sfcode_node_modules_opn_readme_autotoc_md19122}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/opn-cli}{\texttt{ opn-\/cli}} -\/ CLI for this module
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_opn_readme_autotoc_md19123}{}\doxysection{License}\label{md_sfcode_node_modules_opn_readme_autotoc_md19123}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 