Skip to content

Commit

Permalink
Add exit code 2 "broken/circular dependencies were found" to amd-chec…
Browse files Browse the repository at this point in the history
…k for possible CI use
  • Loading branch information
zship committed Sep 1, 2013
1 parent b1b3968 commit de2ef43
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 33 deletions.
8 changes: 8 additions & 0 deletions doc/amd-check.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ which are more likely to be what you're looking for.
--verbose flag.


EXIT STATUS
-----------

0 = ok, no broken or circular dependencies
1 = error occurred during the check
2 = one or more broken or circular dependencies


AMD
---

Expand Down
60 changes: 30 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"name": "amd-cli",
"description": "Diagnostic utilities for projects using the Asynchronous Module Definition format",
"version": "1.0.1",
"homepage": "https://github.com/zship/amd-cli",
"author": "Zach Shipley <zach@zachshipley.com>",
"repository": {
"type": "git",
"url": "https://github.com/zship/amd-cli"
},
"license": "MIT",
"bin": {
"amd": "bin/amd"
},
"directories": {
"man": "./man"
},
"preferGlobal": true,
"dependencies": {
"glob": "3.x",
"libamd": "1.x",
"levenshtein": "1.x",
"mout": "0.x",
"colors": "0.6.x",
"nopt": "2.1.x"
},
"keywords": [
"amd",
"diagnostic",
"cli"
]
"name": "amd-cli",
"description": "Diagnostic utilities for projects using the Asynchronous Module Definition format",
"version": "1.1.0",
"homepage": "https://github.com/zship/amd-cli",
"author": "Zach Shipley <zach@zachshipley.com>",
"repository": {
"type": "git",
"url": "https://github.com/zship/amd-cli"
},
"license": "MIT",
"bin": {
"amd": "bin/amd"
},
"directories": {
"man": "./man"
},
"preferGlobal": true,
"dependencies": {
"glob": "3.x",
"libamd": "1.x",
"levenshtein": "1.x",
"mout": "0.x",
"colors": "0.6.x",
"nopt": "2.1.x"
},
"keywords": [
"amd",
"diagnostic",
"cli"
]
}
11 changes: 8 additions & 3 deletions src/amd-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var check = function() {
return file.magenta + ':' + (loc.line + '').green + ':' + loc.col;
};

var hasBrokenDep = false;
var hasErrors = false;

filePool.forEach(function(file) {
var relative = path.relative('.', file);
Expand All @@ -48,7 +48,7 @@ var check = function() {
return dep.declared.search(/http(s*):/) === -1;
})
.forEach(function(dep) {
hasBrokenDep = true;
hasErrors = true;
switch(dep.type) {
case 'plugin':
log.writeln(formatLocation(relative, dep) + ': "' + dep.pluginName.yellow + '!' + dep.pluginArgs + '" plugin cannot be resolved');
Expand All @@ -66,18 +66,23 @@ var check = function() {
});
});

if (hasBrokenDep) {
if (hasErrors) {
log.warn('Circular dependency check may not complete properly due to broken dependencies!');
}

filePool.every(function(file) {
var cycles = findCircularDependencies(rjsconfig, file);
if (cycles.length) {
hasErrors = true;
log.writeln('Circular dependencies detected. Run "amd circulars" for details.');
return false;
}
return true;
});

if (hasErrors) {
process.exit(2);
}
};


Expand Down

0 comments on commit de2ef43

Please sign in to comment.