Skip to content

Instantly share code, notes, and snippets.

@joe-oli
Created January 1, 2020 14:03
Show Gist options
  • Save joe-oli/ff85d19c36d7ca1528ac6b64154eb4b2 to your computer and use it in GitHub Desktop.
Save joe-oli/ff85d19c36d7ca1528ac6b64154eb4b2 to your computer and use it in GitHub Desktop.
open urls in browser
https://github.com/sindresorhus/open/issues/89
Simple example. the array contains 3 urls;
It iterates thru, logs the urls correctly but only the first url is opened.
urlsArray.forEach(function(urlLine){
opn(urlLine); //for each url... launch in Browser
console.log(urlLine);
});
My environment is Windows / default Browser chrome
Node v 6.11.5
//Author: joe-oli commented on Mar 23, 2018
work around -
opn does not do what i want, use an o/s cmd instead.
var childProc = require('child_process');
urlsArray.forEach(function(urlLine){
var cmd = "start chrome " + urlLine
childProc.execSync(cmd);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment