• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Open urls and files from a grunt task

grunt-open

Open urls and files from a grunt task

Installation

Install using npm in the root of your project directory (where your package.json and Gruntfile.js are located)

npm install --save-dev grunt-open

Usage

This is used as part of your grunt tasks, between the server and watch tasks

grunt.registerTask('default', ['server', 'open', 'watch']);

You can specify different configurations so that you can set up task chains (see the configuration below for this example's config)

grunt.registerTask('dev', ['server', 'open:dev', 'watch']);
grunt.registerTask('build', ['build', 'server', 'open:build', 'watch:build');

Gruntfile Configuration

This is a very simple task and takes two configuration parameters, path (required) and app (optional). If app is not specified, the default system browser will be launched

grunt.initConfig({
  open : {
    dev : {
      path: 'http://127.0.0.1:8888/src',
      app: 'Google Chrome'
    },
    build : {
      path : 'http://google.com/',
      app: 'Firefox'
    },
    file : {
      path : '/etc/hosts'
    },
    custom: {
      path : function () {
        return grunt.option('path');
      } 
    }
  }
})

grunt.loadNpmTasks('grunt-open');

Options

openOn

Type: String

While it may not be common, you may want to delay the opening of your path at a later time of the grunt process. The option openOn allows you to define an event (coming through from grunt.event) that would signal the expected triggering of open. Example:

grunt.initConfig({
  open: {
    delayed: {
      path: 'http://localhost:3000',
      app: 'Google Chrome',
      options: {
        openOn: 'serverListening'
      }
    }
  }
});

grunt.registerTask('server', function () {
  var server = require('myServer');
  server.listen(3000, function (err) {
    if (!err) {
      grunt.log.writeln('Server started');
      grunt.event.emit('serverListening'); // triggers open:delayed
    }
  });
})

delay

Type : Number

Set a delay for the open. Note: This task moves on immediately. If this is the last task in your chain you run the risk of node exiting before your open is called.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

  • 0.2.3 merged support for functions in config, added delay, merged openOn
  • 0.2.2 added app parameter.
  • 0.2.0 grunt 0.4.0 support, added and preferring path parameter.
  • 0.1.0 initial release

License

MIT License, see LICENSE for details.

More Repositories

1

node-to-rust

Rust
1,372
star
2

preprocess

Preprocess HTML, JavaScript, and other files with directives based off custom or ENV configuration
JavaScript
363
star
3

grunt-preprocess

Preprocess files based off environment configuration
JavaScript
294
star
4

JavaScript-Particle-System

2d JavaScript Particle System with gravity field simulation
JavaScript
242
star
5

grunt-env

Grunt task to automate environment configuration for future tasks
JavaScript
224
star
6

grunt-plato

Generate static analysis reports with plato through grunt
JavaScript
206
star
7

hackium

TypeScript
175
star
8

shift-refactor

A suite of utilities to query and modify JavaScript source
TypeScript
131
star
9

jquery.pulse.js

jQuery Pulse Animation Plugin
CSS
82
star
10

puppeteer-interceptor

Easy request interception/response modification for puppeteer
TypeScript
51
star
11

rcl

A websocket bridge for debug logging from browser to server
JavaScript
44
star
12

grunt-contrib-jasmine-example

Example application to help get you started using jasmine through grunt
JavaScript
42
star
13

grunt-strip

Strip JavaScript nodes (like console.*) out of your source code
JavaScript
42
star
14

deobfuscating-js-streams

JavaScript
27
star
15

gitfaq

organized git faq
SCSS
26
star
16

workshop-reverse-engineering

JavaScript
23
star
17

shift-interpreter

TypeScript
22
star
18

jsconsole

JavaScript console/repl styled after chrome devtools.
JavaScript
22
star
19

RetwisJS

Port of Redis's Twitter clone, retwis for node.js
19
star
20

puppeteer-extra-interceptor

Puppeteer-extra plugin for puppeteer-interceptor
TypeScript
18
star
21

es6repl

reusable babel repl
JavaScript
15
star
22

Backbone.Augment

Simple plugin/addon functionality for Backbone Views, Models, and Collections.
JavaScript
15
star
23

puppeteer-extensionbridge

Expose the Chrome extension API to puppeteer
TypeScript
13
star
24

javascript-deobfuscation-AMA

General questions about deobfuscating JavaScript
13
star
25

grunt-jasmine-runner-example

Example setup for grunt-jasmine-runner
JavaScript
12
star
26

badjs.org

CSS
12
star
27

shift-query-cli

Command line tool to query AST nodes in JavaScript source files.
JavaScript
11
star
28

combolist-generator

JavaScript
10
star
29

texture.js

Basic implementation of normal mapped textures in javascript
JavaScript
10
star
30

stream-unzip

A streaming unzip library for rust projects
Rust
9
star
31

html5hub-particlesystem

Particle System demo for html5hub
JavaScript
8
star
32

js-identifiers

JavaScript
8
star
33

karma-commonjs-example

Example repo showing commonjs tests running on command line as well as in karma
JavaScript
7
star
34

shift-visualizer

Visualizer for the Shift AST format
JavaScript
5
star
35

string-format

Sprintf inspired string format method.
JavaScript
5
star
36

typescript-boilerplate

Boilerplate TypeScript project with mocha, eslint, prettier, and Visual Studio Code preconfigured
TypeScript
4
star
37

refactor-plugin-common

TypeScript
4
star
38

shift-identifiers

Find similar identifiers across a source file
JavaScript
4
star
39

marionette.augment.inlineregions

JavaScript
4
star
40

grunt-require-dir

Task to bundle up a directory of AMD modules into one accessor module
JavaScript
3
star
41

fromgit

TypeScript
3
star
42

shift-complexity

Complexity analysis for JavaScript source code.
JavaScript
3
star
43

liquid-json

A library to parse structured JSON with embedded liquid templates
Rust
3
star
44

apex-wip

TypeScript
3
star
45

hackium-plugin-visiblecursor

JavaScript
3
star
46

box2d-intro-amd

Seth Ladd's excellent box2d intro migrated to a modular structure with requirejs.
JavaScript
3
star
47

gh-cloneall

Utility to clone all github repos for a user or organization
JavaScript
3
star
48

concentric-circle-illusion

Visualization on html canvas of the classic optical illusion http://i.imgur.com/p2yeT.jpg
JavaScript
3
star
49

AMD_RequireJS-slides

Talk given to SanDiegoJS on Jan 10, 2012
JavaScript
2
star
50

believable

TypeScript
2
star
51

randomfarts.com

HTML
2
star
52

AMD-urlParams

A query string parser in AMD format for require.js, curl.js, etc
JavaScript
2
star
53

auto-cli-replay

Automatically create CLI GIFs with simulated typing, dynamic interactivity, and more.
Shell
2
star
54

git-spread

Run git commands across multiple directories
Shell
2
star
55

es6-repl

web component wrapping the es6repl
JavaScript
2
star
56

interpreter-context-jsdom

TypeScript
2
star
57

widl2json

WIDL to JSON converter
JavaScript
2
star
58

hackium-plugin-preserve-native

TypeScript
2
star
59

chrome-devtools-slides

Slides for sandiego.js July talk
JavaScript
2
star
60

jsperf-common

List of good jsperf benchmarks for common situations
1
star
61

browserusage.org

Site to simply display worldwide browser usage stats.
CSS
1
star
62

wacl

Rust
1
star
63

perl-Parallel-Forking-Manager

Thread manager for Moose objects with role 'Forking'
Perl
1
star
64

gcp-simple-secrets

TypeScript
1
star
65

cordova-flashcard-app

Objective-C
1
star
66

perl-MooseX-Role-Forking

Forking/Threading role for Perl Moose
Perl
1
star
67

refactor-plugin-unsafe

TypeScript
1
star
68

lockyourdamncomputer.com

CSS
1
star
69

phaser-mario

JavaScript
1
star
70

python-game

Python
1
star
71

example-cli

Rust
1
star
72

gh-action-test

TypeScript
1
star
73

dotfiles

Shell
1
star
74

jsoverson.github.com

stub
1
star
75

fromgit-test

1
star
76

mp-tuning

Rust
1
star
77

allfaqs

HTML
1
star
78

wapc-rust-template

Makefile
1
star
79

apex-template

TypeScript
1
star
80

seeded-random-utils

TypeScript
1
star
81

wit-example

Rust
1
star
82

d3-starter

basic repo that includes what's necessary to experiment with d3
CSS
1
star