Giter Site home page Giter Site logo

open's Introduction

open's People

Contributors

alan-agius4 avatar anaisbetts avatar anubhavsrivastava avatar arthurvr avatar bendingbender avatar coreyfarrell avatar crshoverride avatar ddantzler avatar deansheather avatar ericmandel avatar gaumala avatar haroonrafi avatar herberttn avatar jentevh avatar jonaskuske avatar kazarmy avatar kudo avatar kuzalekon avatar leslieyip02 avatar ltm avatar pikax avatar pluma avatar richienb avatar rush avatar sindresorhus avatar tim-stasse avatar trysound avatar watson avatar webreflection avatar xirzec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

open's Issues

Respect Chrome Devtools URLs

I'm building a simple debugging tool for the awesome Node API framework Lux, which uses node --inspect. Node's new built in inspector spits back a chrome-devtools:// url, which I'd like to open automatically.

However, opn doesn't seem to respect chrome-devtools URLs, even when I pass Google Chrome explicitly as the application to open. I'm therefore resorting to using a MacOSx-only solution of opening the URL using an osascript.

Is there an easy fix for whitelisting chrome-devtools URLs?

Detecting failures

I'm trying to use opn to open a URL. The script is running in a shell process on a remote Ubuntu server. Since there's no GUI, no browser opens, which makes sense. But I can't tell if it worked or not, since the return value of opn is undefined either way, and the callback doesn't get called either way.

Another solution might be to attempt to open lynx...

Strips querystring from URL if it precedes with # in Windows 10 - Chrome

Following code works fine - opens the exact URL in chrome.

var open = require("opn");
open('http://codef0rmer.github.io/eShell/index.html#/1?name=foobar', {app: 'chrome'});

However, if Chrome is a default browser and it's not mentioned then both hash and querystrings are stripped.

var open = require("opn");
open('http://codef0rmer.github.io/eShell/index.html#/1?name=foobar');

Any idea why spawn strips querystring?

Incorrectly add "^" before "&" in url query strings

I haven't really looked into index.js for this problem, but this doesn't occur on all urls. This only occurs when I have a space in the url I am trying to open.
To reproduce this issue on windows 10, do opn('https://www.google.com/#q=12 3&*', {app: 'Chrome'}) and the url in the browser will be https://www.google.com/#q=12 3^&*, however, if I do opn('https://www.google.com/#q=123&*', {app: 'Chrome'}) the url opened in the browser is not modified.
I noticed there is a regex replacement target.replace(/&/g, '^&') in index.js, but im not sure why it doesn't replace all the &s with ^&

bin file?

I would like to use opn in my package.json.
E.g. "start": "npm run open & ecstatic . --defaultExt htm"

just one question regarding lib.

my application is hosted on digital ocean server.
so my question is: can i open a browser from access the app url or api url in my local system.
please reply me.
because i hosted my app and when i trying to open a url from api link, its not opening any browser in my local system where i access this url.

Unnecessary quotation marks?

On Windows, this is passing '""' as the first argument to start to avoid start interpreting a quoted filename as the title of a console window. As it turns out, this seems to be automatically escaped just like the filename itself: if I run opn("cmd"), I get a cmd window with the title \\ (I guess the quotes disappear but the attempt to escape them does not), whereas if I change '""' to just '' or "" I get a cmd window with no title as expected. This does not appear to affect running any actual file/url one way or the other (opn("some file") still works right), so it doesn't really matter as far as functionality, but I wanted to point it out as far as theoretical correctness goes. File under "fun fact" I guess.

(It also seems that instead of a blank window title, an actual window title could be given; but I'm not sure that's useful, between the fact that there are better ways to open a console from Node and the fact that a blank window title would be odd but not confusing whereas any name hardcoded in opn could be irrelevant in whatever hypothetical usage did cause cmd to be opened through opn.)

Support pkg

It could be nice if "opn" package support Zeit "pkg" :) .

Currently, building a cross-platform packages with "pkg" don't work well with "opn", it do nothing and browser don't open :

Error: spawn /snapshot/deploy/node_modules/opn/xdg-open ENOENT 

I will try some solution and update the issue, but i think "pkg" doesn't work with bash script (xdg-open is not packaged).

fails to open multiple URLs on Edge "coldstart"

If MS Edge is closed by the time opn is invoked, running this script results in only the first URL being loaded:

const opn = require('opn');
const urlList = ['https://github.com/sindresorhus/opn', 'https://www.google.com'];
urlList.map(opn); // assuming Edge is the system default browser

If another browser is used (e.g. firefox) it works as expected (i.e. it opens multiple instances of the browser if it's closed, or it opens multiple tabs inside the same browser instance if there is one available - this is true for Edge too).

Saving page

Is there any functionality for saving opened page?

TypeError: Bad argument childProcess.spawn(cmd, args, opts)

var gulp = require('gulp');
var opn = require('opn');

var _open = function () {
    opn('http://sindresorhus.com', {app: 'firefox'});
}   

gulp.task('open', function () {
    _open();
});
~      

[email protected] /home/one/github/torq-ui
└── [email protected] 

[12:45:55] Starting 'open'...
[12:45:55] 'open' errored after 1.47 ms
[12:45:55] TypeError: Bad argument
  at ChildProcess.spawn (child_process.js:936:24)
  at Object.exports.spawn (child_process.js:736:9)
  at module.exports (/home/one/github/torq-ui/node_modules/opn/index.js:58:24)
  at _open (/home/one/github/torq-ui/gulp/tasks/open.js:5:5)
  at Gulp.<anonymous> (/home/one/github/torq-ui/gulp/tasks/open.js:9:5)
  at module.exports (/home/one/github/torq-ui/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
  at Gulp.Orchestrator._runTask (/home/one/github/torq-ui/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
  at Gulp.Orchestrator._runStep (/home/one/github/torq-ui/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
  at Gulp.Orchestrator.start (/home/one/github/torq-ui/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
  at /usr/lib64/node_modules/gulp/bin/gulp.js:129:20
  at process._tickCallback (node.js:419:13)
  at Function.Module.runMain (module.js:499:11)
  at startup (node.js:119:16)
  at node.js:906:3

Bug opening file path html file with query param

System: Linux (Ubuntu 14.04)
opn version: 5.1.0
xdg-open version: 1.1.2

File path with query param doesn't work:

$ ~/node_modules/opn/xdg-open /some/path/index.html?hi
xdg-open: file '/usr/local/google/home/chenwilliam/lighthouse/plots/charts/index.html?hi' does not exist

File path without query param works as expected and opens page in Chrome:

$ ~/node_modules/opn/xdg-open /some/path/index.html
Created new window in existing browser session.

Regular URL path with query param works:

https://www.paulirish.com/?hi

Seems related to this issue? https://bugs.freedesktop.org/show_bug.cgi?id=45857

Open iTerm and run command inside

I have tried to open iTerm and run a command inside, but it fails. Here is the snippet:

opn('ls', { app: '/Applications/iTerm 2.app' });

It tries to open the file named ls.

Using ChildProcess Promise

Hi Team,
Can someone push a example of using the promise that contain child process. I want to get the handle to child process and kill the process after certain period of time..

E.g
opn(imagePath,{wait : true}).then((cProcess) => {
console.log("closed");
cProcess.on('exit', (code) => {
console.log(Child exited with code ${code});
});

setTimeout(function(cProcess) { /* do something with this after 3000 */} , 3000);
});

  1. wait() is not working in windows. As soon as i start the process, it opens up the IMAGE VIEWER and get closed on its own.
  2. I want image viewer to be active for 3 seconds and then i can close it manually.
    Any help will be appreciated.

How to know what app name to use

I see the app can be specified with {app: 'name'}

How do I know or look up what the app name need to be to correspond to a particular program?

I want to open a url with Chrome Canary instead of my default browser (Chrome) but I've tried various names without it working. This is on Windows but is there a OS generic way to check the app names?

Unhandled promise rejection in Docker

(node:16) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with code 3

I apparently get this error when I open links using the module in Docker container. I tested the code in my local before I put the code on my server which uses Docker. And It literally works well in my local that doesn't use Docker. So I assume that something is wrong with docker but there's actually no way to figure out what the problem is. Is there anyone who has ever used 'opn' module with Docker?

Additionally, after I set node version of my server to the same as my local one, It doesn't says the promise error but still doesn't open any links.

How can I close an application ?

Hello,

Thanks to your job I'm able to open an application (an Excel file in my case).
Do you know something to close this Excel application after some processing that I need to do ?

Thank you,
Mathieu

its not working on hosting server.

app.get('/url', function (req, res) {
    try {
        opn('http://google.com/', {app: 'firefox'});
    } catch (e) {
      console.log(e);
    }
  });

I have used this code in my nodejs file.
this code works perfectly in localhost but not working on hosting server.
when i access "domain.com/url" then it give me error and firefox not open at all.

The errors are like this:
0|my-api | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|my-api | Error: spawn firefox ENOENT
0|my-api | at exports._errnoException (util.js:1020:11)
0|my-api | at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
0|my-api | at onErrorNT (internal/child_process.js:367:16)
0|my-api | at _combinedTickCallback (internal/process/next_tick.js:80:11)
0|my-api | at process._tickDomainCallback (internal/process/next_tick.js:128:9)

Please help me to access the url and open browser that mentioned in parameters.
i have hosted this app on digitalocean.
what should i do to run the code perfectly and open browser.

Reuse existing tab in Chrome

I need following functionality:

  • If tab with url is opened in Browser - ist should be only activated.
  • No new tab with the same url should be opened.

Have the promise resolve after the browser has been opened ?

currently there is no option to have the promise fulfill when the browser has been opened. Only either when the browser has been exited or immediately after execution by setting wait to false.
Is there a way to figure out when it has been successfully opened so i can activate a macro when its happened ?

Avoid losing focus

Hi,
I am using this module with Grunt to display errors in the browser
while coding. However, the focus (on the editor) is lost after opening the browser, which is not very handy.
It would be nice if there could be an option to disable this behavior, but I am not sure
how it could be implemented cross-platform. For OS X, passing -g to the open command
should be ok, but I cannot find any equivalent for xdg-open.
Any ideas?

[Question] How to quit opened apps?

Hi @sindresorhus,

it seems like there’s currently no way to quit opened apps, since opn doesn’t return anything and the callback function gets executed once the corresponding app was terminated. Am I missing something?

Incorrect default app openend by xdg-open version 1.0.2

The incorrect default app is opened by xdg-open (1.0.2) when providing an url.
The system provided xdg-open (1.1.0 rc3) opens the correct default app.

Could it be possible to check if xdg-open exists before using xdg-open provided by the package?
Updating xdg-open to at least 1.1.0-rc1 also opens the correct app.

Open default IDE?

I was just wondering if this was possible. Some people on our team use Atom, others Sublime, and I'd like to use opn to open the project directory (root folder, i.e. '.') in the user's default IDE.

Arrow functions causing compatibility issues

Hello,

I see in 5.0.0 that arrow functions were introduced. This unfortunately made the module incompatible with the Chromium Embedded Framework version I have to use for my product.
I'd understand if ES6 compatibility is required going forward, but it'd be great to keep using whatever improvements you introduce without needing to keep my own local edits or being stuck on an old version. As such, I'd ask that you reconsider.

Thank you!

ES2015ify

In for es2015ifying this module and dropping all the dependencies? Or just a little bit too early?

Open new Tab

Hi,
Can I open a new tab instead of opening a new window?

Best.

Add ability to hide cmd window.

On windows when you run opn it opens a new .cmd every time you call it. It would be really nice if there was an option to hide those.

Unhandled promise rejection

(node:43) Error: Exited with code 3
at ChildProcess.cp.once.code (/frontend/node_modules/opn/index.js:82:13)
at Object.onceWrapper (events.js:318:30)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:921:16)
at Socket.stream.socket.on (internal/child_process.js:348:11)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at Pipe._handle.close [as _onclose] (net.js:549:12)
at emitWarning (internal/process/promises.js:69:15)
at emitPendingUnhandledRejections (internal/process/promises.js:86:11)
at runMicrotasksCallback (internal/process/next_tick.js:124:9)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:43) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

On newer versions of node, I receive this message.

Cannot detect when a browser tab has been closed.

After I open an URL in a new tab, I need to wait until the tab has been closed in order to execute some operations. It seems that opn cannot detect it and you need to kill the whole browser processes in order to continue the code execution (supposing that {wait: true} has been used).

Tried with Chrome and Firefox, same result. It's probably hard to detect the pid of the opened tab as the browser (at least Chrome in this case) seems to create a new child process for the tab, which is not detected by opn.
I'm wondering if there is any workaround for this.

spawn cmd ENOENT

I am a novice, I do not know why it has been guaranteed wrong, it is troubled, and for a long time did not fix it, I hope you can help me, thank you very much.
const opn = require('opn');

opn(' http://sindresorhus.com ');

Incognito Not Working

Following your example for spawning an incognito session in Chrome doesn't appear to work anymore.

opn('http://sindresorhus.com', {app: ['google chrome', '--incognito']});

The above command, from your readme, opens the window in Chrome, but not in incognito mode.

OSX: 10.12.2
Chrome: 56.0.2924.87

characters after & get stripped out

require('opn')('http://httpbin.org/get?wan=one&tu=two&tree=three');

expected url: http://httpbin.org/get?wan=one&tu=two&tree=three
actual url: http://httpbin.org/get?wan=one
platform: windows 😏

"google-chrome --incognito" won't open, opens normally without flag.

I caught some very strange behaviour and could not think of any possibility on how to solve it.

In grunt-contrib-connect v0.8, I used "google-chrome --incognito" to develop in incognito mode.

Now that opn has been introduced in v0.9, chrome is not launched with this flag.

If I use simply google-chrome or firefox, it works perfectly.

I logged the cmd variable before execFile and it seems OK.

Any ideas?

Usage with React

Hi, I'd like to use this library in react for a dashboard I'm building for my company. The problem is that I cannot seem to get this to work in React using ES6 syntax. Is there any way I can get this to work? Or if not, could you recommend any alternatives?

Support data URI

opn data:,Hello%2C%20World!

should open the data URI in the browser but does nothing (OS X)

spawn EACCES: Error: spawn EACCES

I tried your library in ubuntu
what could be the error :

var openurl = require('opn');
openurl("http://url.com");

It gives error as :

spawn EACCES: Error: spawn EACCES
    at exports._errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at Object.exports.spawn (child_process.js:399:9)
    at module.exports (/home/lekhnath/.vscode/extensions/Shan.code-settings-sync-2.8.0/node_modules/opn/index.js:74:26)
    at Commons.<anonymous> (/home/lekhnath/.vscode/extensions/Shan.code-settings-sync-2.8.0/out/src/commons.js:189:25)
    at Generator.next (<anonymous>)
    at fulfilled (/home/lekhnath/.vscode/extensions/Shan.code-settings-sync-2.8.0/out/src/commons.js:4:58)
e.onUnexpectedError @ workbench.main.js:29
(anonymous) @ workbench.main.js:29
e.onUnexpectedError @ workbench.main.js:28
o @ workbench.main.js:28
t.onUnexpectedExtHostError @ workbench.main.js:28
e.handle @ workbench.main.js:28
s @ workbench.main.js:28
f @ workbench.main.js:28
_combinedTickCallback @ internal/process/next_tick.js:67
_tickCallback @ internal/process/next_tick.js:98

Does not work in linux system

I faced this error :

Error: Exited with code 3
at ChildProcess.cp.once.code (/etc/nginx/node_modules/opn/index.js:82:13)
at ChildProcess.g (events.js:292:16)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Socket. (internal/child_process.js:342:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.