From ae06afc50b2d067797727a88c273eb909ad8b1c0 Mon Sep 17 00:00:00 2001 From: Cory Forsyth Date: Wed, 20 Apr 2016 16:04:58 -0400 Subject: [PATCH] Update broccoli build to copy version from package.json to src/js/version.js --- Brocfile.js | 18 +++++++++++++++--- README.md | 1 - package.json | 1 + src/js/version.js | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Brocfile.js b/Brocfile.js index b7215700c..e846b62d1 100644 --- a/Brocfile.js +++ b/Brocfile.js @@ -9,6 +9,7 @@ var styles = require('./broccoli/styles'); var jquery = require('./broccoli/jquery'); var injectLiveReload = require('broccoli-inject-livereload'); var LiveReload = require('tiny-lr'); +var replace = require('broccoli-string-replace'); var vendoredModules = [ {name: 'mobiledoc-html-renderer'}, @@ -41,10 +42,21 @@ watcher.on('change', function() { } }); +function replaceVersion(tree) { + var version = require('./package.json').version; + return replace(tree, { + files: ['**/*.js'], + pattern: { + match: /##VERSION##/g, + replacement: version + } + }); +} + module.exports = mergeTrees([ - builder.build('amd', buildOptions), - builder.build('global', buildOptions), - builder.build('commonjs', buildOptions), + replaceVersion(builder.build('amd', buildOptions)), + replaceVersion(builder.build('global', buildOptions)), + replaceVersion(builder.build('commonjs', buildOptions)), styles(), injectLiveReload(testTree) ]); diff --git a/README.md b/README.md index 475059c65..dcca52aa9 100644 --- a/README.md +++ b/README.md @@ -304,7 +304,6 @@ in `demo/`. To run the demo: #### Releasing -* update version in `src/js/version.js` * Update version in `package.json` * `npm run update-changelog` * commit with message `v` (e.g. "v0.9.0") diff --git a/package.json b/package.json index b7ffa1dff..328eefeb0 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "broccoli-merge-trees": "^1.0.0", "broccoli-multi-builder": "^0.2.8", "broccoli-sane-watcher": "^1.1.4", + "broccoli-string-replace": "^0.1.1", "broccoli-test-builder": "^0.2.0", "conventional-changelog": "^1.1.0", "conventional-changelog-cli": "^1.1.1", diff --git a/src/js/version.js b/src/js/version.js index 6f237b2d4..2034b2955 100644 --- a/src/js/version.js +++ b/src/js/version.js @@ -1 +1 @@ -export default '0.9.3'; +export default '##VERSION##';