title: Grunt - pass filename variable from command line
body: <p>I am struggling to understand how I can pass a partial filename from the grunt command line, in order to run a task (from an installed grunt module) on a particular file.</p>
  
  <p>What I want to be able to do is configure a series of tasks to take filename parameter from the command line.</p>
  
  <p>I've tried reworking the final example on this page <a href="http://chrisawren.com/posts/Advanced-Grunt-tooling" rel="nofollow">http://chrisawren.com/posts/Advanced-Grunt-tooling</a> but I'm kind of stabbing in the dark a bit. Thought someone would have a quick answer.</p>
  
  <p>Here is my Gruntfile:</p>
  
  <pre><code>module.exports = function (grunt) {
      grunt.initConfig({
        globalConfig: globalConfig,
  
          uglify: {
            js: {
              options: {
                mangle: true
              },
              files: {
                'js/&lt;%= globalConfig.file %&gt;.min.js': ['js/&lt;%= globalConfig.file %&gt;.js']
              }
            }
          },
  
  
  
      });
  
      // Load tasks so we can use them
  
  
  
      grunt.loadNpmTasks('grunt-contrib-uglify');
  
      grunt.registerTask('go', 'Runs a task on a specified file', function (fileName){
        globalConfig.file = fileName;
        grunt.task.run('uglify:js');
      });
  };
  </code></pre>
  
  <p>I attempt to run it from the command line like this:</p>
  
  <pre><code>grunt go:app
  </code></pre>
  
  <p>to target js/app.js</p>
  
  <p>I get this error:</p>
  
  <pre><code>Aborted due to warnings.
  roberts-mbp:150212 - Grunt Tasks robthwaites$ grunt go:app
  Loading "Gruntfile.js" tasks...ERROR
  &gt;&gt; ReferenceError: globalConfig is not defined
  Warning: Task "go:app" not found. Use --force to continue.
  </code></pre>
  
  <p>Thanks</p>