concept build task in category javascript

This is an excerpt from Manning's book JavaScript Application Design: A Build First Approach.
When the command completes, you’ll get a detailed report indicating the status of your code. If your code has any problems, the tool will report the expected result and line number for each of those problems. Then it will exit with an error code, allowing you to “break the build” if the lint fails. Whenever a build task fails to produce the expected output, the entire process should be aborted. This presents a number of benefits because it prevents work from continuing if something goes wrong, refusing to complete a build until you fix any issues. Figure 1.9 shows the results of linting a snippet of code.
This chapter focuses on build tasks rather than trying to teach you everything about Grunt. You can always learn to use a new tool, as long as you understand the concepts underlying its goals, but you can’t learn to use other tools properly if you don’t understand those underlying concepts. If you want a deeper understanding of Grunt itself, check out appendix B. Reading that appendix isn’t instrumental to understanding this chapter; however, it does define the Grunt features you’ll use throughout part 1.
We’ll begin this chapter with a quick introduction to Grunt and its core concepts; then you’ll spend the rest of the chapter learning about build tasks and using a few different tools. We’ll look at preprocessing (per Manning MOS) tasks such as compiling code into another language, postprocessing (per Manning MOS) tasks such as asset minification and image spriting, and code integrity tasks such as running JavaScript unit tests and linting CSS code. Then you’ll learn how to write your own build tasks in Grunt, and you’ll look at a case study on writing your own set of database schema update tasks, complete with rollbacks!
You’re pretty much in the same position as you were at the end of chapter 1, where you could lint your JavaScript, except that you’re not. Grunt will help you put together the full-blown build process that’s at the heart of the Build First philosophy. With relative ease, you can focus on different tasks, depending on whether you’re building for local development or diagnostics, or building the end product humans will ultimately consume. Let’s examine a few properties found in build tasks.
The lint task you set up will serve as the basis for a much more powerful build, as you expand your understanding throughout part 1 of the book. This task innocently shows off one of the fundamental properties of build tasks: in the vast majority of cases, they’ll be idempotent—repeated execution of a task shouldn’t produce different results. In the case of the lint task, that might mean getting the same warnings every time, as long as you don’t change the source code. More often than not, build tasks are a function of one or many provided input files. The idempotence property, when paired with the fact that you shouldn’t perform any operations by hand, translates into more consistent results.