Skip to content

Commit

Permalink
[BUGFIX release] Use correct version number when used as an addon.
Browse files Browse the repository at this point in the history
(cherry picked from commit b13a81b)

Conflicts:
	package.json
  • Loading branch information
Robert Jackson authored and bmac committed Jan 12, 2016
1 parent a5220a6 commit 58dabce
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
16 changes: 16 additions & 0 deletions lib/calculate-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var path = require('path');
var existsSync = require('exists-sync');
var gitRepoInfo = require('git-repo-info');

module.exports = function() {
var gitPath = path.join(__dirname, '..', '.git');
var packageVersion = require('../package.json').version;

if (existsSync(gitPath)) {
var info = gitRepoInfo(gitPath);

return packageVersion + '+' + info.sha.slice(0, 10);
} else {
return packageVersion;
}
};
5 changes: 2 additions & 3 deletions lib/version-replace.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var VERSION = require('git-repo-version')(10);
var calculateVersion = require('./calculate-version');
var replace = require('broccoli-string-replace');

module.exports = function configFiles(tree) {
return replace(tree, {
files: ['*.{json,js}'],
pattern: {
match: /VERSION_STRING_PLACEHOLDER/g,
replacement: VERSION
replacement: calculateVersion()
}
});
};

11 changes: 2 additions & 9 deletions lib/version.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
var calculateVersion = require('./calculate-version');
var createFile = require('broccoli-file-creator');

var version;

try {
version = require('git-repo-version')(10);
} catch (e) {
version = require('../package').version;
}

module.exports = function() {
return createFile('version.js', 'export default "' + version + '";');
return createFile('version.js', 'export default "' + calculateVersion() + '";');
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"ember-cli-test-info": "^1.0.0",
"ember-cli-version-checker": "^1.1.4",
"ember-inflector": "^1.9.4",
"exists-sync": "0.0.3",
"git-repo-info": "^1.1.2",
"inflection": "^1.8.0",
"semver": "^5.1.0",
"silent-error": "^1.0.0"
Expand Down Expand Up @@ -69,6 +71,7 @@
"ember-try": "0.0.6",
"ember-watson": "^0.7.0",
"git-repo-version": "^0.3.0",
"github": "^0.2.4",
"glob": "^5.0.13",
"lodash.assign": "^3.2.0",
"mocha": "^2.3.4",
Expand Down

0 comments on commit 58dabce

Please sign in to comment.