jsoverson / grunt-open Goto Github PK
View Code? Open in Web Editor NEWOpen urls and files from a grunt task
License: MIT License
Open urls and files from a grunt task
License: MIT License
What do you think about accepting a callback function as an option which can be called after grunt open is finished? Would you be open to adding it to this module?
If i need to open more than one page the grunt open task doesn't allow for the ability to using the following syntax:
open: {
url1: {
server: {
url: 'http://localhost:<%= express.options.port %>/index.html'
}
},
url2: {
server: {
url: 'http://localhost:<%= express.options.port %>/index2.html'
}
}
}
Or am i missing something? What is the way to do so?
using setTimeout
, which is, to some extent, much better than onOpen
I made grunt open task on the next way:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
open : {
AngularSeedApp : {
path: 'http://127.0.0.1:8888/app/index.html',
//app: 'Google Chrome'
},
});
grunt.loadNpmTasks('grunt-open');
After this I run in command line:
grunt open
and chrome runs and I got this
Oops! Google Chrome could not connect to 127.0.0.1:8888
Try reloading: 127.0.0.1:8888/app/index.html
How I can solve this issue that I get my preview of index.html in browser (chrome is my default).
Add chromium-browser
support in app
.
I'm currently running a concurrent task that watches my files, starts my server and opens the browser. Due to the nature of my server it blocks all other scripts from being executed afterwards. So whenever my browser gets opened, I get a blank screen. Immediately after pressing f5 the page is loaded fine. A slight delay would fix this.
Many thanks,
Yoshua
Is it possible to add support for which browser (or browsers) should be executed ?
In testacular it is avaiable. There are configs for each supported browser (e.g. Chrome, Firefox ).
I think that in config could be option launchers
where will be added default launchers for file
. ( no browsers
, cause in future users could add others configurations for programs which would be launched on open, e.q. editor )
i generate a html report (tests fail case), and then want to open it, only if its generated. I want to ignore the open task (skip with success), in case there is no report-file. (tests success case)
Is there a simple way without pull-request or another npm package?
I'm posting this issue to let you know that we will be publishing Grunt 0.4 on Monday, February 18th.
If your plugin is not already Grunt 0.4 compatible, would you please consider updating it? For an overview of what's changed, please see our migration guide.
If you'd like to develop against the final version of Grunt before Monday, please specify "grunt": "0.4.0rc8"
as a devDependency in your project. After Monday's release, you'll be able to use "grunt": "~0.4.0"
to actually publish your plugin. If you depend on any plugins from the grunt-contrib series, please see our list of release candidates for compatible versions. All of these will be updated to final status when Grunt 0.4 is published.
Also, in an effort to reduce duplication of effort and fragmentation in the developer community, could you review the grunt-contrib series of plugins to see if any of your functionality overlaps significantly with them? Grunt-contrib is community maintained with 40+ contributors—we'd love to discuss any additions you'd like to make.
Finally, we're working on a new task format that doesn't depend on Grunt: it's called node-task. Once this is complete, there will be one more conversion, and then we'll never ask you to upgrade your plugins to support our changes again. Until that happens, thanks for bearing with us!
If you have any questions about how to proceed, please respond here, or join us in #grunt on irc.freenode.net.
Thanks, we really appreciate your work!
npm audit
barks an alert to a critical vulnerability with this package.
It returns:
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Critical │ Command Injection │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ open │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ No patch available │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ grunt-open [dev] │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ grunt-open > open │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/663 │
└───────────────┴──────────────────────────────────────────────────────────────┘
Unless you are diligent about closing new tabs, starting and killing grunt many times while debugging eventually the browser will have a sea of identical tabs.
It would be nice if there was an option to request the browser to "reuse" the same tab each time grunt-open
was used.
I haven't looked to see if browsers have this option on the command line. I'm guessing it's not possible to request the browser uses the same tab the way target="name"
works on <a href..
, so this might require a browser extension.
Other ideas how to prevent the sea of tabs from happening?
Your package.json file shows MIT:
"licenses": [
{
"type": "MIT",
"url": "https://github.com/onehealth/grunt-open/blob/master/LICENSE"
}
],
But your LICENSE files shows it as Apache:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Can you sync these up so that they are reported properly?
I have a grunt serve
task that does a build, starts a web server, then uses grunt-open to launch the web page once the server has fully started. I use the openOn
option because it is the most reliable way to ensure that the asynchronous server startup is complete and thereby avoid launching the page before the server is ready.
Unfortunately, the open task continues to run every time the event is fired (in my case, on every server restart). This results in every change to a server-dependent file not just restarting the server but also popping up a new tab in the browser despite the open task running only once at initial startup.
The simplest fix is to replace grunt.event.on(
with grunt.event.once(
. The implementation is a matter of opinion, it might be preferable for backwards compatibility to introduce an openOnceOn
option to explicitly open only once. Either way it would be good to update the documentation for openOn
to specify whether it opens just once or every time the event is triggered.
This is a minimal example to point out the problem.
Assuming a basic grunt installation exists, copy these three files in an empty folder and run npm install
. Next run grunt
. Now a browser should open and load "www.google.com". Then modify and save the test.coffee
file. The browser should open www.google.de
every time you modify the file test.coffee
.
On my system Windows8 x64, node v0.10.13, and grunt v0.4.1 just the first open before "watching" is executed properly.
Gruntfile.coffee
module.exports = (grunt) ->
require('matchdep').filterDev('grunt-*').forEach grunt.loadNpmTasks
grunt.initConfig
watch:
test:
files: ['test.coffee']
tasks: ['open']
open:
server:
path: 'http://www.google.com'
grunt.registerTask 'live', [
'open'
'watch'
]
grunt.registerTask 'default', ['live']
package.json
{
"name": "openwatch",
"version": "0.0.1",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"matchdep": "~0.1.2",
"grunt-contrib-watch": "~0.4.4",
"grunt-open": "~0.2.0"
},
"engines": {
"node": ">=0.8.0"
}
}
test.coffee
test = true
Hi,
I am using grunt-open without any problem with Windows 7 but unfortunately it does not open my browser using Ubuntu 13.04. Any advice would be much appreciated. :)
Currently, this task does not use this.options()
to look up the app
option, but explicitly uses this.data.app
or this.data.application
. This breaks multitask shared options configuration.
I keep getting "Warning: Spawn ENOENT" problem when I am running grunt-open.
My setup
I have all my project files on Google Drive. I am doing my development on the files directly on them (using Google Drive desktop).
I just want to open the index.html file when I run grunt. Just that simple.
Part of my Gruntfile.js
open: {
all: {
path : 'index.html'
}
},
But I couldn't get it working? What am I missing?
I have tried the exact Gruntfile code on another machine and it works perfectly fine.
Just mucking around here trying to get a configuration together that starts my server, sets up watches, and opens a browser. I couldn't get grunt-open to work for the longest time, and was getting errors "cannot read property 'orig' of undefined" on the multiTask defined in the module. When I changed the multiTask to a plain task (registerTask), I started getting "cannot read property 'url' of undefined." Reading around, I found some hints that the module might be expecting a "files:" config, even though it's not documented. In the end, I came up with this (using this specific syntax), and everything finally worked:
open: {
all: {
files: { src: ['./index.html'] },
path: 'http://localhost:<%= connect.server.options.port %>',
app: 'chrome'
}
},
Any ideas why I was having this issue? I don't see that anyone else has encountered it. Thanks, and thanks for the package.
This plugin works perfectly on my local machine, however, it doesn't work on my Docker machine. On my local machine the open task
set as following:
server: {
url: 'http://localhost:<%= express.options.port %>'
}
On my Docker machine as following:
server: {
url: 'http://192.168.99.100:<%= express.options.port %>'
}
NOTE: 192.168.99.100 is my VM's ip address on my Mac.
I got the following error:
app_1 | Running "open:server" (open) task
app_1 | Warning: Command failed: /bin/sh -c /www/app/node_modules/open/vendor/xdg-open "http://192.168.99.100:3000"
app_1 | /www/app/node_modules/open/vendor/xdg-open: 1: /www/app/node_modules/open/vendor/xdg-open: xdg-mime: not found
app_1 | xdg-open: no method available for opening 'http://192.168.99.100:3000'
I have been googling for a while but still no luck. Any help would be appreciated.
Having both url
and file
when they don't differ doesn't make sense.
Use path
or uri
for both instead.
grunt-livestyle passes the port in the 'serverListening' event. It would be nice if I could write a function that would use that in the url to be opened.
It seems that the recent modifications three days ago have caused the plugin not to work with grunt-watch unless you set a delay
or perhaps openOn
. I set a delay of 100
and now the watch works fine.
(In my setup, grunt-open is preceded by ericclemmons/grunt-express-server and followed by grunt-watch)
Every time i run grunt-open task i keep getting this
Fatal error: Cannot read property 'replace' of undefined
my task is so simple
open: {
path: 'http://localhost:3000',
app: 'Firefox'
},
kindly help
The 'app' option is ignored in the 0.2.4 release. Whatever the app is set to, the url is always opened in the default browser. Rolled back to 0.2.3 and verified that the option works there.
A fallback mechanism would be cool, if the specified app (browser) wasn't found to use the default browser without failing the task.
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.