Skip to content

Commit

Permalink
Added support for CoffeeScript. Files with extension .coffee will aut…
Browse files Browse the repository at this point in the history
…omatically be compiled on-the-fly.
  • Loading branch information
pahen committed Aug 3, 2012
1 parent a7071bd commit 67fa4ec
Show file tree
Hide file tree
Showing 22 changed files with 134 additions and 127 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ Coming soon ..

$ npm test

# Release Notes

## v0.0.5 (August 8, 2012)
Added support for CoffeeScript. Files with extension .coffee will automatically be compiled on-the-fly.

## v0.0.4 (August 17, 2012)
Fixed dependency issues with Node.js v0.8.

## v0.0.3 (July 01, 2012)
Added support for Node.js v0.8 and dropped support for lower versions.

## v0.0.2 (May 21, 2012)
Added ability to read config file and customize colors.

## v0.0.1 (May 20, 2012)
Initial release.

# License

(The MIT License)
Expand Down
6 changes: 2 additions & 4 deletions lib/analysis/circular.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

/**
* A circular dependency is occurring when we see a software package
* more than once, unless that software package has all its dependencies resolved
*
* more than once, unless that software package has all its dependencies resolved.
* @param {String} id
* @param {Object} modules
* @param {Object} circular
Expand All @@ -30,8 +29,7 @@ function resolver(id, modules, circular, resolved, unresolved) {
}

/**
* Finds all circular dependencies for the given modules
*
* Finds all circular dependencies for the given modules.
* @param {Object} modules
* @return {Object}
*/
Expand Down
3 changes: 1 addition & 2 deletions lib/analysis/depends.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

/**
* Finds all modules that depends on the given modules
*
* Finds all modules that depends on the given modules.
* @param {Object} modules
* @param {String} id
* @return {Array}
Expand Down
5 changes: 2 additions & 3 deletions lib/color.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict';

/**
* Module dependencies
* Module dependencies.
*/
var colors = require('colors');

/**
* Return colored string (or not)
*
* Return colored string (or not).
* @param {String} str
* @param {String} name
* @param {Boolean} use
Expand Down
25 changes: 9 additions & 16 deletions lib/graph.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
'use strict';

/**
* Module dependencies
* Module dependencies.
*/
var exec = require('child_process').exec,
graphviz = require('graphviz'),
g = graphviz.digraph('G');

/**
* Set color on a node
*
* Set color on a node.
* @param {Object} node
* @param {String} color
*/
Expand All @@ -19,8 +18,7 @@ function nodeColor(node, color) {
}

/**
* Set color for nodes without dependencies
*
* Set color for nodes without dependencies.
* @param {Object} node
* @param {String} [color]
*/
Expand All @@ -29,27 +27,24 @@ function noDependencyNode(node, color) {
}

/**
* Check if Graphviz is installed on the system
*
* Check if Graphviz is installed on the system.
* @throws Error
*/
function checkGraphvizInstalled() {
var child = exec('gvpr -V', function (error, stdout, stderr) {
exec('gvpr -V', function (error, stdout, stderr) {
if (error !== null) {
throw new Error('Graphviz could not be found. Ensure that "gvpr" is in your $PATH.\n' + error);
}
});
}

/**
* Creates a PNG image from the module dependency graph
*
* Creates a PNG image from the module dependency graph.
* @param {Object} modules
* @param {Object} opts
* @param {Function} callback
*/
module.exports.image = function (modules, opts, callback) {

checkGraphvizInstalled();

var nodes = {},
Expand Down Expand Up @@ -96,16 +91,14 @@ module.exports.image = function (modules, opts, callback) {
};

/**
* Return the module dependency graph as DOT output
*
* Return the module dependency graph as DOT output.
* @param {Object} modules
* @return {String}
*/
module.exports.dot = function (modules) {

checkGraphvizInstalled();

var nodes = {};

checkGraphvizInstalled();

Object.keys(modules).forEach(function (id) {
var node = nodes[id] = nodes[id] || g.addNode(id);
Expand Down
22 changes: 7 additions & 15 deletions lib/madge.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
require('path').existsSync = require('fs').existsSync;

/**
* Expose factory function
*
* Expose factory function.
* @api public
* @param {String|Array|Object} src
* @param {Object} opts
Expand All @@ -17,15 +16,13 @@ module.exports = function (src, opts) {
};

/**
* Class constructor
*
* Class constructor.
* @constructor
* @api public
* @param {String|Array|Object} src
* @param {Object} opts
*/
function Madge(src, opts) {

this.opts = opts || {};
this.opts.format = String(this.opts.format || 'cjs').toLowerCase();

Expand All @@ -47,8 +44,7 @@ function Madge(src, opts) {
}

/**
* Return the module dependency graph as an object
*
* Return the module dependency graph as an object.
* @api public
* @return {Object}
*/
Expand All @@ -57,8 +53,7 @@ Madge.prototype.obj = function () {
};

/**
* Return the modules that has circular dependencies
*
* Return the modules that has circular dependencies.
* @api public
* @return {Object}
*/
Expand All @@ -67,8 +62,7 @@ Madge.prototype.circular = function () {
};

/**
* Return a list of modules that depends on the given module
*
* Return a list of modules that depends on the given module.
* @api public
* @param {String} id
* @return {Array}
Expand All @@ -78,8 +72,7 @@ Madge.prototype.depends = function (id) {
};

/**
* Return the module dependency graph as DOT output
*
* Return the module dependency graph as DOT output.
* @api public
* @return {String}
*/
Expand All @@ -88,8 +81,7 @@ Madge.prototype.dot = function () {
};

/**
* Return the module dependency graph as a PNG image
*
* Return the module dependency graph as a PNG image.
* @api public
* @param {Object} opts
* @param {Function} callback
Expand Down
20 changes: 6 additions & 14 deletions lib/parse/amd.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

/**
* Module dependencies
* Module dependencies.
*/
var fs = require('fs'),
path = require('path'),
Expand All @@ -10,10 +10,8 @@ var fs = require('fs'),
colors = require('colors'),
Base = require('./base');


/**
* This class will parse the AMD module format
*
* This class will parse the AMD module format.
* @see https://github.com/amdjs/amdjs-api/wiki/AMD
* @constructor
*/
Expand All @@ -27,19 +25,17 @@ var AMD = module.exports = function () {
util.inherits(AMD, Base);

/**
* Normalize a module file path and return a proper identificator
*
* Normalize a module file path and return a proper identificator.
* @param {String} filename
* @return {String}
*/
AMD.prototype.normalize = function (filename) {

var id = path.relative(this.baseDir, filename).replace(this.extRegEx, '');

try {

if (fs.existsSync(filename)) {
var content = fs.readFileSync(filename, 'utf8'),
var content = this.getFileSource(filename),
def = parse(id, filename, content);
if (def) {
var match = def.match(/define\("([^\"]+)"/);
Expand All @@ -60,17 +56,14 @@ AMD.prototype.normalize = function (filename) {
};

/**
* Parse the given file and return all found dependencies
*
* Parse the given file and return all found dependencies.
* @param {String} filename
* @return {Object}
*/
AMD.prototype.parseFile = function (filename) {

try {

var dependencies = [],
src = fs.readFileSync(filename, 'utf8');
src = this.getFileSource(filename);

if (src.indexOf('define(') >= 0 || src.indexOf('require(') >= 0) {
parse.findDependencies(filename, src).filter(function (id) {
Expand All @@ -83,7 +76,6 @@ AMD.prototype.parseFile = function (filename) {

return dependencies;
}

} catch (e) {
if (this.opts.breakOnError) {
console.log(String('\nError while parsing file: ' + filename).red);
Expand Down
Loading

0 comments on commit 67fa4ec

Please sign in to comment.