By Developers, For Developers

Historical errata for Automate with Grunt

PDF PgPaper PgTypeDescriptionFixed onComments
19TYPO

In the “Accessing Configuration inside Tasks” caption at the end of chapter 2:
“But by using this.name() to fetch the task name…” name is a property not a function. The example is right and uses name as a property but the text is wrong.

2014-09-20
19TYPO

Within the inset:
“This lets us to change the tasks’ name”

Need to remove “to”

2014-09-20
44TYPO

At ‘Watching Files for Changes’ in the Gruntfile.js code block for setting up ‘watch’, it says to watch the folder ‘coffeescripts//..’

I think that folder should be ‘coffeescript’ .

2014-09-20
33OK

I cant get `bower install markdown#0.6.0-beta1` to work. It claims no known version. I have the latest version of bower (1.3.3).

I’ve just installed from source instead. :)

2014-09-20Seems to work from here - I get prompted to choose it as the second option and it installs fine.
52TYPO

$ grunt open:http:\\://google.com… this doesn’t work.. need to double escape, at least with mac…

$ grunt open:http\\\\://google.com <—- this works

2014-09-20
38SUGGEST

In example code: multitasks/angular/Gruntfile.js

I found variable, sources, inside this.files.forEach never be declared with var keyword. The code works fine and has no problem. But, first time I saw this variable, I don’t know it is a local variable or a global one which you already declared somewhere else.

2014-09-20
13TYPO

In the section “Creating a Folder” the first sentence starts with “Grunt’s built-in grunt.util.mkdir() method creates folders”. This should be: “Grunt’s built-in grunt.file.mkdir() method creates folders”.

2014-09-20
22TYPO

About halfway on this page it says “we define the configuration section using grunt.initConfig(),”. This should be “we define the configuration section using grunt.config.init(),”

2014-09-20
38ERROR

I couldn’t get
grunt uglify
to run until I added:

“grunt-contrib-uglify”: “~0.2.2”

to the devDependencies of package.json

This is on fedora 20
npm —version
1.3.6

2014-09-20After retesting I can only assume you missed the --save-dev part of the `npm install grunt-contrib-uglify' command. Works from here.
52TYPO

I’m not sure if it’s just my copy of Grunt, but the statement:
var chromeLauncher = require(‘./lib/chrome_launcher.js’).init(grunt);

doesn’t work when the open_with_chrome.js task lives in the ‘tasks/’ directory.

changing it to:
var chromeLauncher = require(‘../lib/chrome_launcher.js’).init(grunt);

(going up a directory)

Seems to make it work.

2014-09-20Can't seem to reproduce. Adding `../` causes it to break on OSX. \n
11TYPO

The directory in the mkdir statement should be “deploying” not “deployment”.

2014-09-20
22ERROR

The zip codes in the weather config object should be in quotes since some zip codes start with a 0.

2014-09-20That's a great point. Fixed!
21TYPO

The value of “concat.basic.src” in the example reads “[‘src/awsome.js’]”, rather than “[‘src/awesome.js’]”.

2014-09-20
46ERROR

It seems that the `preprocess` lifecycle event doesn’t exist by default. Probably the API has changed and/or the author meant to use the `prepublish` event.

2015-04-23
27-28TYPO

“We can access the targets as an array. We iterate over the targets and grab the sources… On line 3 we iterate over the various targets. In a multitask, we use the files property to access the configured targets and … as Grunt allows for several methods of configuring targets
and destinations.” The word “targets” is the wrong word in each of those sentences. Reword to something like the following: “We can access a target’s configured files as an array of src-dest objects (the normalized ”Files Array file format“, see http:/gruntjs.com/configuring-tasks#files-array-format). We iterate over the array, and grab the sources from each object… On line 3 we iterate over the src-dest objects. In a multitask, we use the files property to access the configured sources and destinations configured for a target… as Grunt allows for several methods of configuring sources and destinations for a target.”

48TYPO

“Grunt comes with grunt.util.spawn(), which is perfect for this.” But then spawn() isn’t used in the code that follows… exec() is used.

2015-04-23
52TYPO

“So, create Gruntfile.js as the package.json file:”

2015-04-23
49TYPO

“With the Revealing Module Pattern we define a function that returns a JavaScript object that we create. This allows us to have both public and private methods on this object.” The returned object is the public interface — it doesn’t have any private methods.

2015-04-23
49TYPO

“With the Revealing Module Pattern we define a function that returns a JavaScript object that we create. This allows us to have both public and private methods on this object.” The returned object is the public interface — it doesn’t have any private methods.

2015-04-23
89TYPO

loadNpmModule should read loadNpmTask.

6ERROR

When I try to run the command grunt addNumbers:1:2 I get a message saying that grunt cannot find the task. See code below.

module.exports = function(grunt){
// Your tasks go here
grunt.registerTask(‘greet’, function(name){
  grunt.log.writeln(‘Hi there, ’ + name);
});

grunt.registerTask(‘addNumbers;, function(first, second) {
  var answer = Number(first) + Number(second);
  grunt.log.writeln(first + ’ + ’ + second + ’ is ’ + answer);
});

grunt.registerTask(‘default’, function(){
grunt.log.writeln(‘Hello from Grunt.’);
\t
});

}

Categories: