Commit 14c1f1b9 14c1f1b98a33ea7b064669f74800e264d28f8def by Nicolas Perriault

bootstrap.js now throws CasperError in case package.json does not contain valid version information

1 parent 30c45923
...@@ -131,16 +131,16 @@ phantom.loadCasper = function() { ...@@ -131,16 +131,16 @@ phantom.loadCasper = function() {
131 var fs = require('fs'); 131 var fs = require('fs');
132 pkgFile = fs.absolute(fs.pathJoin(path, 'package.json')); 132 pkgFile = fs.absolute(fs.pathJoin(path, 'package.json'));
133 if (!fs.exists(pkgFile)) { 133 if (!fs.exists(pkgFile)) {
134 throw new Error('Cannot find package.json at ' + pkgFile); 134 throw new CasperError('Cannot find package.json at ' + pkgFile);
135 } 135 }
136 try { 136 try {
137 pkg = JSON.parse(require('fs').read(pkgFile)); 137 pkg = JSON.parse(require('fs').read(pkgFile));
138 } catch (e) { 138 } catch (e) {
139 throw new Error('Cannot read package file contents: ' + e); 139 throw new CasperError('Cannot read package file contents: ' + e);
140 } 140 }
141 parts = pkg.version.trim().split("."); 141 parts = pkg.version.trim().split(".");
142 if (parts < 3) { 142 if (parts < 3) {
143 throw new Error("Invalid version number"); 143 throw new CasperError("Invalid version number");
144 } 144 }
145 patchPart = parts[2].split('-'); 145 patchPart = parts[2].split('-');
146 return { 146 return {
......