Skip to content
Andrew Pennebaker edited this page May 9, 2013 · 5 revisions

CSS Lint uses a build system to make updating code faster and easier. Doing so allows a simple, clean directory and file structure that is easy to navigate and expand upon without needing to reference dozens of JavaScript files in a page. Understanding the build system is key to working with the CSS Lint source code.

Installing Ant

In order to build CSS Lint, you must first download and install Ant. Ant is a Java-based command line build tool that works with the build.xml file found in the root directory.

If you're using Windows, you can install Ant via Chocolatey:

cinst apache.ant

If you're using Mac OS X, Ant is already installed for you. If for some reason it's not installed, be sure to install MacPorts and run:

sudo port install apache-ant

If you're using Ubuntu, you can simply type:

sudo apt-get install ant

Other operating systems should refer to http://ant.apache.org/manual/install.html for more information.

Installing Node.js

The CSS Lint build system requires Node.js to run its unit tests. Go to http://nodejs.org to download and install the latest stable version for your operating system.

Most of the installers come with npm already installed, but if for some reason it doesn't work on your system, you can install it manually using the instructions on the website.

Installing YUI Test

The CSS Lint unit tests are written using YUI Test, which you can install using npm via:

npm install -g yuitest

The build targets

Ant works by defining build targets. A target is really just a collection of steps to take. CSS Lint has several build targets:

  • build.core - builds the core CSS Lint JavaScript library
  • build.worker - builds the CSS Lint JavaScript Web Worker
  • build.rhino - builds the CSS Lint JavaScript CLI for Rhino
  • build.node - builds the CSS Lint JavaScript CLI for Node.js
  • build.tests - combines all unit tests into a single file
  • build.docs - processes the documentation files and places them in the build directory
  • build.all - executes all of the previous targets (those beginning with build.)
  • changelog.update - automatically updates the CHANGELOG file with change information (admin use only)
  • lint - runs lint tools on the source code to find possible errors
  • release - prepares an official release by inputting version numbers and copying files to release directory (admin use only)
  • parser.update - downloads the latest version of the CSS parser and installs it in the lib directory
  • test - builds everything, runs lint tools on the source code, and runs all unit tests on the command line

In order to run a particular target, go into the csslint directory and use the following command:

ant <target>

For instance, if you just want to build the tests, run this:

ant build.tests

If you want to build everything, type:

ant build.all

Since build.all is the default target, you can shorten this by simply typing:

ant

When there is no target specified on the command line, Ant will automatically use the default. build.all is the most frequently run target so it is set as the default.

Note: It's important that you run this command only in the csslint directory. Builds do not work in subdirectories.

The build.xml file

Ant uses the build.xml to define targets and other related information. In general, you won't ever need to touch this file unless you're creating a new build target.

The property csslint.version is defined at the top of the file. This version number is embedded in the source files when the release target is run. This value should not be changed except by the CSS Lint maintainers.

Workflow

Whenever you make changes to the CSS Lint source files, you'll need to run the build.all target to regenerate the combined source files. The workflow is:

  1. Make changes
  2. Run ant test to build and run tests on the command line

If you want to run CSS lint on node against a specific css file during development, your workflow will need to be a bit different.

  1. Make changes
  2. Run ant test to build and run tests on the command line
  3. Edit build/npm/package.json give it a version number like 1.0.0
  4. Run [sudo] npm link (in the build/npm dir)
  5. Run csslint <options> <file-name>

You'll have to do this each time you make a change. It can be helpful to begin development using only tests, then when the code is more or less stable, test it against specific files.

Clone this wiki locally