stephenlacy / gulp-open Goto Github PK
View Code? Open in Web Editor NEWOpen files and URLs with gulp (http://gulpjs.com)
License: MIT License
Open files and URLs with gulp (http://gulpjs.com)
License: MIT License
gulp.src('./src/index.html')
.pipe(open({url: 'http://localhost:8080/'}));
0.3.1 version normal open http://localhost:8080,
after the upgrade to open the browser 1.0.0 default is file:///home/{xxxxxxxx}/src/index.html
should is http://localhost:8080
Hi all,
Just a quick question.
I installed Gulp-open with the following codes on gulpfiles.js:
gulp.task( 'open', function() {
var options = {
uri: uri,
app: 'chrome' || 'google chrome' // may need to sniff for Windows/OSX to determine Chrome string
};
gulp.src( './build/' )
.pipe( open( options ) );
});
I also have gulp-connect and gulp-yargs with the following:
var src = './build',
dist = './build',
baseURL = ( argv.production === undefined ) ? src : dist,
port = ( argv.production === undefined ) ? 8000 : 8001,
uri = 'http://localhost:' + port;
gulp.task( 'connect', function() {
connect.server( {
root: baseURL,
livereload: true,
port: port
} );
} );
I'm not sure what is happening, on the package.json the dependency is there, but gulp can't find it.
Any ideas what's happening?
Thank you in advance.
Kind regards,
Fernando Fas
Love the plugin, used it on a few projects for a while now.
The Issue
Here is my gulp task which does not open chrome:
gulp.task('open', function() {
return gulp.src('./index.html')
.pipe(open('', {
url: 'http://localhost:8000',
app: 'chrome' // "chrome" per the docs
}));
});
The Fix
Using app: 'google chrome'
does work and is case insensitive.
System Info
Mac OSX Mavericks (10.10.1)
gulp-open 0.3.1
Gulp
CLI version 3.8.9
Local version 3.8.10
Thanks!
When I add .pipe( open() )
to my gulp task, the process never exits - I must hit Cmd+C in order to type the next prompt. Without this addition, it does exit.
Maybe I'm doing something wrong, but following the examples doesn't work for me. I've tried Chrome, Firefox and the default (which is Chrome) and it doesn't open anything.
First thanks for a great package.
My issue is that i use google chrome profiles to target different user logins on various sites and I wanted to know if it was possible to target a specific profile?
My env is Windows 7, Visual Studio Code, my typical usage is developing SharePoint Spfx solutions to test on lots of different dev/test Office 365 tenants (hence why I have a ton of google chrome profiles and it would be awesome to know if I can target a specific profile).
TIA
Hi! This plugin could be very useful for me. I have a weird issue, though: In every browser I try it opens the url using parallels desktop, when it should just open it on my osx. Any ideas? Here is my code:
gulp.task('app', function(){
var browser = os.platform() === 'linux' ? 'google-chrome' : (
os.platform() === 'darwin' ? 'google chrome' : (
os.platform() === 'win32' ? 'chrome' : 'firefox'));
var options = {
uri: 'localhost:3000',
app: browser
};
gulp.src('./')
.pipe( open(options) );
});
Hi, can you add the google chrome browser definition for OS X to the readme?
'google-chrome' // Linux
'chrome' // Windows
'Google Chrome' // OS X
'firefox'
You mentioned in #18 that you were considering opn
over node-open
.
Presently, node-open
is broken on Linux - I get Error: spawn open ENOENT
because the open
command doesn't exist on Linux. A workaround for my use case has been to symlink xdg-open
to open
, but that's super inelegant, and might well break for other use cases.
Since node-open
is deprecated anyway, do you anticipate making a switch anytime soon? I'm happy to submit a PR.
Feature Request:
Hey there!
Can you implement an option to forbid opening if the url to open is already open?
greets Charlie
This would be useful to me.
Also, would it ever be possible to run post-open commands (for instance should I want to open developer tools, load a specific snippet, etc. after the file is open)?
Hi,
grunt open was working for me by setting %CHROME_BIN%
but the gulp version is not, I followed the readme, but no win.
Hi, I would like to know if it is possible to open IE with gulp-open?
thanks
You should also solidify your dep versions by using npm install --save <module name>
This line checks whether the file is null and throws an error if it's not. This prevents users from passing { read: false }
to gulp.src
(because in that case, file.isNull()
returns true), but since this task doesn't use the contents of the file, you should be able to pass { read: false }
to optimize the flow (you only need the file path to open it). I realize that means it's possible to attempt to open a file that doesn't exist, but in that case, you'll just get an error, which is no different than the current behavior.
Hi,
I'm simply trying to open a path with the default OS browser (using Node v4.2.0).
I noticed though that if the browser already has other tabs opened nothing happens: what am I doing wrong?
gulp.task('open', function(){
gulp.src(__filename).pipe($.open({uri: 'localhost:4050'}));
});
Thanks!
There should be some way to refresh the currently opened browser so that you can reload/refresh the page when some file changes. This would make it easier for developing static websites and phonegap/cordova applications
My pipeline function
function openhtml(done){
return gulp.src('dist/**/*.html')
.pipe(open({app: 'chrome'}, done));
}
First file will open, but next files this error ocurres:
Opening my.html using the app chrome
The following tasks did not complete: dev, openhtml
Did you forget to signal async completion?
0.3.2 is the latest version published to npm, please update npm version
In version 2.1.0 I was still able to use directory paths (e.g. "../") as uri and they would open correctly in the desired app (that is atom).
In version 3.0 the directory is opened in the default app instead (that is finder), although the output in the terminal states that it will be opened in the desired app, and the task runs forever instead of exiting correctly.
I am on macOS.
Hello,
Open an url doesn't work, I don't see what I forgot or not?
This is my code:
var gulp = require('gulp');
var open = require('gulp-open');
gulp.task('open', function () {
var options = {
url: 'http://localhost:9000',
app: 'google chrome' // OSX
};
gulp.src('./app/scripts/index.html')
.pipe(open('', options));
});
Hi Steve,
I want to be able to open a url without a filename:
or
Gulp-open doesn't seem to launch the browser without me specifying a filename? So I'm probably doing something wrong, how can I go about doing this?
Thinking of something similar to: https://github.com/jjrdn/node-open
Hi question about chrome on OS X 10.9.5 (13F34).
My Code:
gulp.task("open", function(){
var platform = os.platform();
var chrome = platform === 'win32'?'chrome':'google-chrome';
var browsers = [chrome,'safari','firefox'];
browsers.forEach(function(mybrowser){
var options = {
url: "http://localhost:"+connectPort,
app: mybrowser
};
console.log(options);
gulp.src(rootApp+"/index.html")
.pipe(open("", options));
})
});
firefox safari open the tap but chrome doesn`t i do something wrong ?
my log returns :
[17:29:45] Server started http://localhost:9100
[17:29:45] LiveReload started on port 35729
{ url: 'http://localhost:9100', app: 'google-chrome' }
{ url: 'http://localhost:9100', app: 'safari' }
{ url: 'http://localhost:9100', app: 'firefox' }
It would be really nice to be able to pass options arguments to the plugin
i.e.,
gulp.task('open-chrome', function(){
var options = {
uri: 'http://localhost:3000',
app: 'chrome',
options: '--open-fullscreen'
};
gulp.src(__filename)
.pipe(open(options));
});
Is it possible to open chrome and enable dev tools?
i have a ticket system server and a dev server.
Is there anyway to open both urls in the same window?
thx in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.