grunt-wait-port

Grunt task to run a server, wait for its port to open, then run another task.
Works only on Unix-based systems.

Installation

Add the following to your package.json:

  "grunt-wait-port": "git+https://github.com/vintasoftware/grunt-wait-port.git",

Add the folloing to your grunt.js. Here, we assume you have two tasks defined, run_server and run_tests:

grunt.loadNpmTasks('grunt-wait-port');

grunt.initConfig({

  //...

  waitport: {
    test: {
      options: {
        server: ['run_server'],
        port: 3000,
        other: ['run_tests']
      }
    }
  }

  //...

});

Shortcuts

Create shortcut tasks by giving common tasks easy names.

grunt.registerTask("test", 'build waitport:test');

Output

By default, waitport will ignore the output of server and will show the output of other task.
You can override this by using the stdioServer and stdioOther options, which accept values according node.js child_process.spawn stdio param