Skip to content

Commit

Permalink
In example app, properly handle case where a project doesn't have a r…
Browse files Browse the repository at this point in the history
…eadme.
  • Loading branch information
miccolis committed Jul 27, 2012
1 parent 704e61f commit a069100
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/simple/models/Project.server.bones
Expand Up @@ -33,9 +33,11 @@ models.Project.prototype.sync = function(method, model, options) {
fs.readdir(projectDir, function(err, files) { fs.readdir(projectDir, function(err, files) {
if (err) return callback('Project not found.'); if (err) return callback('Project not found.');


var found = false;
for (var i = 0; i < files.length; i++) { for (var i = 0; i < files.length; i++) {
var match = re.exec(files[i]); var match = re.exec(files[i]);
if (match) { if (match) {
found = true;
fs.readFile(projectDir +'/'+ match.input, 'utf8', function(err, data) { fs.readFile(projectDir +'/'+ match.input, 'utf8', function(err, data) {
if (err) return callback('Could not retrieve project information.'); if (err) return callback('Could not retrieve project information.');
// 80 chars folks... // 80 chars folks...
Expand All @@ -46,6 +48,7 @@ models.Project.prototype.sync = function(method, model, options) {
break; break;
} }
} }
if (!found) return callback('Project is missing a readme file.');
}); });
} }


Expand Down

0 comments on commit a069100

Please sign in to comment.