HTML and CSS Reference
var spriter = require('../spriter');
The only change is the addition of the process.argv , which passes in the first argument after the
script name to the script.
You can now run the spriter command from the command line; passing the name of a directory of
images and the script should output two files in the directory you run the script from: sprites.json and
If this were to be a production-ready script to be made available via npm, you would most likely want to al-
low more options to be passed in to the script to control the outputted files and regular expression used to match
files. All that code is relatively boilerplate code that you can work out yourself from existing modules. Most of
the time the scripts you write for yourself are going to be razor-focused on helping you automate your build and
deployment process, so handling a hundred and one different options is left as an exercise for you.
After you have your module working, you can create a tarball of that directory and use npm install ,
passing in the name of the tarball to install that module on different computers. See the instructions on npmjs.org
for more details at http://npmjs.org/doc/install.html .
If you want to publish your module to npm's list of packages so that it can be installed directly by name
via npm install , look at the documentation for the npm publish command at http://npmjs.org/doc/ pub-
Now you have Node.js up and running; you've installed a few modules and used the scripts therein to lint and
minify your code. You also wrote your own module and script to generate a sprite map and corresponding JSON
file that you can use in later chapters to prevent the need to create sprite maps by hand and calculate positions
of individual sprites and frames. You revisit Node in Chapter 19, “Building a Canvas Editor,” and Chapter 21,
“Going Real Time,” when you use it as a web server for writing multiplayer games, which is a use case Node