Commit 30c45923 30c4592385307e954b751dee8fcba2a5e5bc1388 by Nicolas Perriault

version number is now centralized to package.json

1 parent 09cedfce
CasperJS Changelog
==================
XXXX-XX-XX, v0.6.5
------------------
- fixed 0.6.4 version number in `bootstrap.js`
- centralized version number to package.json
2012-02-09, v0.6.4
------------------
......
......@@ -29,21 +29,6 @@
*/
phantom.loadCasper = function() {
// see http://semver.org/
phantom.casperVersion = {
major: 0,
minor: 6,
patch: 3,
ident: undefined,
toString: function() {
var version = [this.major, this.minor, this.patch].join('.');
if (this.ident) {
version = [version, this.ident].join('-');
}
return version;
}
};
// Patching fs
// TODO: watch for these methods being implemented in official fs module
var fs = (function(fs) {
......@@ -140,6 +125,39 @@ phantom.loadCasper = function() {
});
}
// CasperJS version, extracted from package.json - see http://semver.org/
phantom.casperVersion = (function getVersion(path) {
var parts, patchPart, pkg, pkgFile;
var fs = require('fs');
pkgFile = fs.absolute(fs.pathJoin(path, 'package.json'));
if (!fs.exists(pkgFile)) {
throw new Error('Cannot find package.json at ' + pkgFile);
}
try {
pkg = JSON.parse(require('fs').read(pkgFile));
} catch (e) {
throw new Error('Cannot read package file contents: ' + e);
}
parts = pkg.version.trim().split(".");
if (parts < 3) {
throw new Error("Invalid version number");
}
patchPart = parts[2].split('-');
return {
major: ~~parts[0] || 0,
minor: ~~parts[1] || 0,
patch: ~~patchPart[0] || 0,
ident: patchPart[1] || "",
toString: function() {
var version = [this.major, this.minor, this.patch].join('.');
if (this.ident) {
version = [version, this.ident].join('-');
}
return version;
}
};
})(phantom.casperPath);
/**
* Retrieves the javascript source code from a given .js or .coffee file.
*
......
Subproject commit 0f3b4b30a0f87a9dca740f887cb4e60a6a96e409
Subproject commit e46d6689f5cee8d66cd6f2952f8f41d8635f0ea0
......