Socket
Socket
Sign inDemoInstall

opener

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

opener

Opens stuff, like webpages and files and executables, cross-platform


Version published
Maintainers
1
Weekly downloads
7,985,972
decreased by-6.24%

Weekly downloads

Package description

What is opener?

The opener npm package is a utility that allows you to open files, URLs, executables, and directories with their default application from Node.js. It is a cross-platform package that works on Windows, macOS, and Linux.

What are opener's main functionalities?

Open URLs in the default web browser

This feature allows you to open a URL in the user's default web browser. It is useful for redirecting users to web pages from a Node.js application.

const opener = require('opener');
opener('http://www.google.com');

Open files in the default application

This feature enables you to open a file with its associated default application. For example, a PDF would be opened in a PDF viewer.

const opener = require('opener');
opener('path/to/file.pdf');

Open directories in the default file explorer

With this feature, you can open a directory in the system's default file explorer, which can be handy for showing users where certain files are located.

const opener = require('opener');
opener('path/to/directory/');

Other packages similar to opener

Readme

Source

It Opens Stuff

That is, in your desktop environment. This will make actual windows pop up, with stuff in them:

npm install opener -g

opener http://google.com
opener ./my-file.txt
opener firefox
opener npm run lint

Also if you want to use it programmatically you can do that too:

var opener = require("opener");

opener("http://google.com");
opener("./my-file.txt");
opener("firefox");
opener("npm run lint");

Plus, it returns the child process created, so you can do things like let your script exit while the window stays open:

var editor = opener("documentation.odt");
editor.unref();
// These other unrefs may be necessary if your OS's opener process
// exits before the process it started is complete.
editor.stdin.unref();
editor.stdout.unref();
editor.stderr.unref();

Use It for Good

Like opening the user's browser with a test harness in your package's test script:

{
    "scripts": {
        "test": "opener ./test/runner.html"
    },
    "devDependencies": {
        "opener": "*"
    }
}

Why

Because Windows has start, Macs have open, and *nix has xdg-open. At least according to some person on StackOverflow. And I like things that work on all three. Like Node.js. And Opener.

FAQs

Last updated on 29 Aug 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc