Skip to content

Commit

Permalink
In 'meteor --version', print the git sha of the checkout used at inst…
Browse files Browse the repository at this point in the history
…all time.
  • Loading branch information
n1mmy committed Mar 15, 2012
1 parent bb57513 commit d318a1c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
18 changes: 18 additions & 0 deletions app/lib/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var https = require("https");
var path = require("path");
var semver = require("semver");

var files = require("./files.js")

var manifest_options = {
host: 's3.amazonaws.com',
path: '/com.meteor.static/update/manifest.json'
Expand Down Expand Up @@ -55,3 +57,19 @@ exports.needs_upgrade = function (version) {

return semver.lt(exports.CURRENT_VERSION, version);
};


exports.git_sha = function () {
var d = files.get_dev_bundle();
var f = path.join(d, ".git_version.txt");

if (path.existsSync(f)) {
try {
var contents = fs.readFileSync(f, 'utf8');
contents = contents.replace(/\s+$/, "");
return contents;
} catch (err) { }
}

return null;
};
11 changes: 10 additions & 1 deletion app/meteor/meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,16 @@ var main = function() {

if (argv.version) {
var updater = require('../lib/updater.js');
process.stdout.write("Meteor version " + updater.CURRENT_VERSION + "\n");
var sha = updater.git_sha();

process.stdout.write("Meteor version " + updater.CURRENT_VERSION);

if (files.in_checkout())
process.stdout.write(" (git checkout)");
else if (sha)
process.stdout.write(" (" + sha.substr(0, 10) + ")");

process.stdout.write("\n");
process.exit(0);
}

Expand Down
3 changes: 3 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ CPR packages "$TARGET_DIR"
mkdir -p "$PARENT/bin"
rm -f "$PARENT/bin/meteor"
ln -s "$TARGET_DIR/bin/meteor" "$PARENT/bin/meteor"

# mark directory with current git sha
git rev-parse HEAD > "$TARGET_DIR/.git_version.txt"

0 comments on commit d318a1c

Please sign in to comment.