grunt-openport-async

0.1.2 • Public • Published

grunt-openport-async

Gets next open port async so grunt config tasks i.e. load-grunt-config can occur after an open port is available. Can be called multiple times.

Install

npm i -D grunt-openport-async

Usage

Typically you'd get the next available port and set it so configs can use it.

require('grunt-openport-async')(grunt)
.then(function(port) {
  // Recommended: set the available port for use in other configs
  grunt.config('port', port);
  // Or do grunt.initConfig() here
});

I recommend using load-grunt-config to have a clean grunt config setup. grunt-openport-async queues all tasks run after it so you can run load-grunt-config sequentially and have the tasks run in sequence.

require('grunt-openport-async')(grunt)
.then(function(port) {
  grunt.config('port', port);
});

// port is available via grunt.config.get('port') when your configs are
// loaded by load-grunt-config
require('load-grunt-config')(grunt, {
  jitGrunt: true
});

Options

See openport for all the options you can pass as the second argument.

require('grunt-openport-async')(grunt, {
  startingPort: 1024,
  endingPort: 2000,
  avoid: [1025, 1500]
})
.then(function(port) {
  // Handle results
});

Package Sidebar

Install

npm i grunt-openport-async

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • tlee