Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more flexible config #7

Closed
sebv opened this issue Nov 18, 2012 · 10 comments
Closed

more flexible config #7

sebv opened this issue Nov 18, 2012 · 10 comments

Comments

@sebv
Copy link

sebv commented Nov 18, 2012

Right now configuration is not flexible, would be good to be able to declare several server config or even rename the task to server for example, without having to for your own task.

The change below would let you configure like this:

    connect: {
      dev: {
        port: 3010,
        base: 'app/public',
        keepalive: true
      },
      dist: {
        port: 3011,
        base: 'dist/public',
        keepalive: true
      }
    },
var config = target ? grunt.config(['connect' , target]) : grunt.config('connect');
var options = grunt.util._.defaults(config, {

The change below would let you change the task name (maybe there is a better way)

var config = grunt.config([grunt.task.current.name].concat(grunt.task.current.args));
var options = grunt.util._.defaults(config, {
@shama
Copy link
Member

shama commented Nov 18, 2012

You should be able to specify multiple targets and reference them with grunt connect:dev, grunt connect:dist or grunt connect for all targets.

You can also rename tasks with grunt.renameTask or simply register a new task to point to one or more other tasks: grunt.registerTask('server', ['connect']);

@sindresorhus
Copy link
Member

Also, the option thing is already built into grunt 0.4.

Just do:

connect: {
  options: {
    keepalive: true
  }
  dev: {
    options: {
      port: 3010,
      base: 'app/public'
    }
  },
  dist: {
    options: {
      port: 3011,
      base: 'dist/public'
    }
  }
},

@sebv
Copy link
Author

sebv commented Nov 18, 2012

Yeah but did you test it? It doesn't seem to work.

It is due to the way you retrieve the config:

grunt.config('connect')

It doesn't follow the task definition, if the task isn't called connect, the config is not used.

Edit: Am using grunt 0.4.

@shama
Copy link
Member

shama commented Nov 18, 2012

Oh you're right @sebv. It looks like that changed in this commit. I'm not sure why.

@sebv
Copy link
Author

sebv commented Nov 18, 2012

Better ask sindre for advice, there should be guidelines from grunt on the best way to get the config.

But I've debugged it, the problem now is that your config return a complex configuration object rather than flat options.

@sindresorhus sindresorhus reopened this Nov 18, 2012
@sindresorhus
Copy link
Member

@cowboy Why the change to not support targets?

@cowboy
Copy link
Member

cowboy commented Nov 20, 2012

I don't think it ever supported targets. But it totally can, now's the time to do it! Want to make a PR?

@sindresorhus
Copy link
Member

@cowboy I'm pretty sure it did before this commit ccd5ab9#L7L21

@cowboy cowboy closed this as completed in 8035c8c Nov 20, 2012
@cowboy
Copy link
Member

cowboy commented Nov 20, 2012

Let me know what you think of my changes!

@sebv
Copy link
Author

sebv commented Dec 1, 2012

Thx @Cowboys it works fine. Maybe, just for this task, it'll be worth explaining in the doc how to rename the task to server. If you are migrating or doing things like this, it's nicer to be able to keep the server task name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants