Grunt : argument with colon - gruntjs

I'd like to pass an url to a grunt task. Unfortunately the separator used by grunt is the colon which is also present in an url.
So how could I pass a url as argument to a grunt task ?

I went for the grunt.option('optionName') way.
from the command line it's called like following :
grunt myTask --optionName=httpmyUrl

Related

Is there a way to send multiple values for grunt.option

I'd like start grunt with an option set with multiple vales. Is this possible?
i.e.
grunt doThis --ip 1.2.3.4 --ip 2.3.4.5
Is this possible?
grunt.registerTask('doThis', function () {
console.log(grunt.option('ip'));
});
grunt doThis --ip="192.168.1.1" --ip="192.169.1.10"
Running "doThis" task
192.169.1.10
Done, without errors.
Yes. Grunt uses nopt to parse the command line options and it supports multiple values. You'd pass them like this:
grunt doThis --ip=1.2.3.4 --ip=2.3.4.5
You'll need at least version v1.0.0-rc1 of Grunt for this to work.

How to pass an option to a Grunt task using WebStorm?

I have a Gruntfile.js in my project, which is parsed by WebStorm (JetBrains IDE for Javascript). The parsed tasks appear in the Grunt view.
Considering the following task (see http://gruntjs.com/frequently-asked-questions#options) :
grunt.registerTask('upload', 'Upload code to specified target.', function(n) {
var target = grunt.option('target');
// do something useful with target here
});
How can I run grunt upload --target=staging using WebStorm ? I can't find a way to pass the option.
to specify custom CMD options (retrieved via grunt.option()) passed to Grunt task, use Tasks field of Grunt Run configuration, like: 'print -–echo=Hello' (or 'upload --target=staging' in your case)

Grunt Uglify Leading to Error

I started using Grunt to build my app; used the uglify module to minify my scripts . Loading the minified file leads to an error
Original : https://github.com/mayur-arora/imageDrive/blob/master/scripts/content_script.js
Minified:https://github.com/mayur-arora/imageDrive/blob/master/scripts/content_script.min.js
If I manually add "})" at the end of the minified file, it works. But should I have to do this ? Why does Uglify get it wrong ?
Similar is the case with
Original:https://github.com/mayur-arora/imageDrive/blob/master/scripts/imageDrive.js
and
minified:https://github.com/mayur-arora/imageDrive/blob/master/scripts/imageDrive.min.js
This one has - unexpected token var
I used 'remove-logging' before 'uglify' and now it works fine. Uglify followed by 'remove-logging' was causing this.

Yeoman Webapp in combination with Assemble

I'm trying to get the default Yeoman Webapp to work with Assemble.io.
I followed this tutorial Using assemble.io with yeoman.io’s webapp Gruntfile
Got it up & running (partially), the first problem I have is that livereload isn't kicking in when changes are made to the .hbs files. When I manually refresh, I can see the changes that were made.
This is my Grunt file.
Second problem is that 'grunt build' gives me the following error:
Running "requirejs:dist" (requirejs) task
{ [Error: Error: Missing either an "out" or "dir" config value. If using "appDir" for a full project optimization, use "dir". If you want to optimize to one file, use "out".
at Function.build.createConfig ([MY DIRECTORY]/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:25109:19)
]
originalError: [Error: Missing either an "out" or "dir" config value. If using "appDir" for a full project optimization, use "dir". If you want to optimize to one file, use "out".] }
I googled around & when I add the following to requirejs:dist:options
appDir: '<%= yeoman.app %>/', dir: 'build'
Then this error is solved, but the next appears:
No "concat" targets found.
Warning: Task "concat" failed. Use --force to continue.
Versions:
Yeoman 1.0.4
Node 0.10.21
Bower 1.2.7
Grunt-cli 0.1.9
Grunt 0.4.1
Anyone seeing the problem? Thanks!
See this line in your gist. It's trying to call a task called concat in your Gruntfile, but that task doesn't exist. There may have been a change with the Yeoman webapp generator or you might have had a copy/paste issue or something. The assemble part of your Gruntfile looks fine.
I think you can remove the concat and carry on.

Zsh alias not working as in bash

I use this alias in my .bashrc but doesn't seem to work in zsh using .zshrc. Other aliases I use are working fine so I know the .zshrc is sourcing other aliases.
alias rubydev3="cd ~/code/ruby/rails/rails3projects/"
This is the error message:
cd:cd:10: no such file or directory: /home/jryan/code/ruby/rails/rails3tutorial/
I don't know if the cd:cd:10 means anything that should be a clue, but I am just starting to use zsh so I'm at a loss. If the command should work as I have it in this post that I'm sure it probably has something to do with another config file conflicting or something like that.
Try defining a function instead of an alias:
function rubydev3 {
builtin cd ~/code/ruby/rails/rails3projects/
}
Is the error message issued when you try to use the alias or during the processing of ~/.zshrc? I notice that the error message has a different directory than the alias. Try this command:
type -a rubydev3
It will show you how "rubydev3" is defined.
It's possible that it's getting redefined.
Also, it's possible that cd has been aliased and that's interfering. To fix that, use this:
alias rubydev3="builtin cd ~/code/ruby/rails/rails3projects/"
On the off chance - Are you using rvm? This adds functionality to cd, try turning it off.
export rvm_project_rvmrc=0

Resources