jsoverson / grunt-open

Open urls and files from a grunt task
MIT License
110 stars 19 forks source link

Allow dynamic destinations #16

Closed apaleslimghost closed 10 years ago

apaleslimghost commented 10 years ago

Lets you specify a destination as a function, e.g.

grunt.initConfig({
  open: {
    url: function (env) {
      return 'http://localhost:'+envs[env].port;
    }
  }
});

var envs = {local: {port: 8080}, test: {port: 8081}};

grunt.task.run('open:local');
apaleslimghost commented 10 years ago

Whoops, just noticed #11. Um.

I prefer my approach as it lets you pass arguments through from the task?

markhicken commented 10 years ago

If it will work that's great because it doesn't rely on the path dependency. What I was after is the ability to specify a relative path in the gruntfile.js and have it translated to a full path. For example...

gruntfile.js

grunt.initConfig({
    // relative paths
    projectConfig = {
        dev: 'project/dev', 
        build: 'project/build'
    },

    open: {
        url: '<%= projectConfig.build %>' + 'index.hta' // full path translated by path.resolve(dest);
    }
});

In this example, 'project/build' becomes something like 'C:\Users\Me\Projects\project\build\'. I'm not sure how to do this type of translation with a function inside the Grunt config. Is it possible?

jsoverson commented 10 years ago

Closing and using the other PR since I don't want the arguments passed to the task exposed for future compatibility and coupling issues.