My favorites | Sign in
Project Logo
             
Search
for
Updated Apr 30, 2008 by stekolla
JSCompile  
How to use JSCompile

What is JSCompile?

JSCompile is a Python script that concatenates and minifies JavaScript files.

Used without any options, this script will search the current directory for a build file (defaults to 'build.txt'), parse that file to get a list of JavaScript files, concatenate the contents of those files and then save a production (defaults to 'all.js', minified using jsmin) and a debug (defaults to 'all-debug.js', unminified) version of the output.

Using the all flag will cause the script to perform its operations on the current directory and any subdirectories (ignoring .svn directories).

Using the lint flag will cause the script to run each JavaScript file through JSLint before it is compiled.

Using the noexecute flag will cause the script to ignore any execute statements found in the build file.

Using the noprompt flag will cause the script to not prompt before running any execute statements.

Passing values for the build, prod or debug flags will tell the script to use the passed values instead of the default values.

Usage

jscompile [-h|--help] [-a|--all] [-l|--lint] [-X|--noexecute] [-P|--noprompt] [-b|--build <file>] [-p|--prod <file>] [-d|--debug <file>]

Using it in this manner assumes that you can execute the command 'python' from the command line. You may have to tweek the shebang line in the file in order to get this to work.

You can also run this script in the following manner:

python jscompile <options>

Options

-h, --help Displays help message.
-a, --all Look in the current directory and any subdirectories for build files.
-l, --lint Run JSLint on all files (requires Rhino & JSLint).
-X, --noexecute Ignore any execute statements.
-P, --noprompt Do not prompt before running any execute statements.
-b, --build Name of the build file.
-p, --prod Name of the target production file.
-d, --debug Name of the target debug file.

Build Files

A build file is a simple text file that should specify one JavaScript file or one directory, relative to the build file's location, per line. Subdirectories of specified directories will also be searched. Files that don't end in '.js' will be ignored.

Empty lines are ignored.

Lines beginning with '//' are treated as comments and ignored.

The following statements can also be added to the build file and will override any default settings or settings that were passed in on the command line.

production <file> The target production file
debug <file> The target debug file
lint [yes|no] Yes to run the JavaScript files through JSLint
run [yes|no] Yes to run any execute statements
prompt [yes|no] Yes to prompt before running any execute statements
execute <command> Run the specified command. The command can be any command that can be executed from the command line.

Dependencies

Python - The Python programming language.


Sign in to add a comment
Hosted by Google Code