Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
add kanso version used to build app to ddoc metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Caolan McMahon committed Jan 25, 2012
1 parent 0edd1b8 commit 7acf1b2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bin/kanso
Expand Up @@ -40,12 +40,12 @@ kansorc.load(function (err, settings) {
usage();
}
else if (cmd === '-v' || cmd === '--version') {
utils.readJSON(__dirname + '/../package.json', function (err, pkg) {
utils.getKansoVersion(function (err, ver) {
if (err) {
return logger.error(err);
}
logger.clean_exit = true;
console.log(pkg.version);
console.log(ver);
});
}
else if (cmd in commands) {
Expand Down
8 changes: 7 additions & 1 deletion lib/packages.js
Expand Up @@ -85,7 +85,13 @@ exports.load = function (name, paths, source, options, callback) {
}
doc.kanso.config = rcfg;
doc.kanso.build_time = utils.ISODateString(new Date());
callback(null, utils.stringifyFunctions(doc), rcfg);
utils.getKansoVersion(function (err, ver) {
if (err) {
return callback(err);
}
doc.kanso.kanso_version = ver;
callback(null, utils.stringifyFunctions(doc), rcfg);
});
});
});
});
Expand Down
13 changes: 13 additions & 0 deletions lib/utils.js
Expand Up @@ -669,3 +669,16 @@ exports.catchAuthError = function (fn, url, extra_args, callback) {
}
}));
};

/**
* Reads the version property from Kanso's package.json
*/

exports.getKansoVersion = function (callback) {
exports.readJSON(__dirname + '/../package.json', function (err, pkg) {
if (err) {
return callback(err);
}
return callback(null, pkg.version);
});
};
3 changes: 2 additions & 1 deletion test/testapps/intersecting_ranges/output.json
Expand Up @@ -10,6 +10,7 @@
},
"minify": false
},
"build_time": "2012-01-08T00:11:12Z"
"build_time": "2012-01-08T00:11:12Z",
"kanso_version": "0.1.4"
}
}
3 changes: 2 additions & 1 deletion test/testapps/postprocessors/output.json
Expand Up @@ -10,6 +10,7 @@
},
"minify": false
},
"build_time": "2012-01-08T00:11:28Z"
"build_time": "2012-01-08T00:11:28Z",
"kanso_version": "0.1.4"
}
}
3 changes: 2 additions & 1 deletion test/testapps/preprocessors/output.json
Expand Up @@ -12,6 +12,7 @@
},
"minify": false
},
"build_time": "2012-01-08T00:11:37Z"
"build_time": "2012-01-08T00:11:37Z",
"kanso_version": "0.1.4"
}
}

0 comments on commit 7acf1b2

Please sign in to comment.