Skip to content

Commit

Permalink
Fixed issue Mikhus#69: added version string to minified sources and p…
Browse files Browse the repository at this point in the history
…rovided possibility to fetch version string from gauges at runtime
  • Loading branch information
Mikhus committed Sep 28, 2016
1 parent 7c085d7 commit dd33d29
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvas-gauges",
"version": "2.0.7",
"version": "2.0.8",
"homepage": "https://github.com/Mikhus/canvas-gauges",
"authors": [
"Mykhailo Stadnyk <[email protected]>"
Expand Down
6 changes: 4 additions & 2 deletions gauge.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gauge.min.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const babel = require('gulp-babel');
const fsc = require('fs-cli');
const semver = require('semver');
const inject = require('gulp-inject-string');
const version = require('./package.json').version;

/**
* @typedef {{argv: object}} yargs
Expand Down Expand Up @@ -70,7 +71,8 @@ function es6concat(type = 'all') {
.pipe(concat('gauge.es6.js'))
.pipe(replace(/((var|const|let)\s+.*?=\s*)?require\(.*?\);?/g, ''))
.pipe(replace(/(module\.)?exports(.default)?\s+=\s*.*?\r?\n/g, ''))
.pipe(replace(/export\s+(default\s+)?(GenericOptions;)?/g, ''));
.pipe(replace(/export\s+(default\s+)?(GenericOptions;)?/g, ''))
.pipe(replace(/%VERSION%/g, version));
}

function license() {
Expand All @@ -80,7 +82,8 @@ function license() {

src.pop();

return '/*!\n * ' + src.join('\n * ') + '\n */\n';
return '/*!\n * ' + src.join('\n * ') + '\n *\n * @version ' +
version + '\n */\n';
}

/**
Expand Down Expand Up @@ -159,7 +162,6 @@ gulp.task('build:prod', done => {
});
});
})).then(() => {
let version = require('./package.json').version;
let cmd = '';

console.log(chalk.bold.green('Production packages are now ready!'));
Expand Down Expand Up @@ -366,7 +368,6 @@ gulp.task('doc', ['clean:docs'], done => {

//move to pages

let version = require('./package.json').version;
let target = '../canvas-gauges-pages/docs/' + version;

rimraf(target, () => fs.rename('docs', target, done));
Expand Down
20 changes: 20 additions & 0 deletions lib/BaseGauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ const Animation = require('./Animation');
const Collection = require('./Collection');
const DomObserver = require('./DomObserver');

const version = '%VERSION%';

const round = Math.round;
const abs = Math.abs;

let gauges = new Collection();

gauges.version = version;

/**
* Basic abstract BaseGauge class implementing common functionality
* for different type of gauges.
Expand Down Expand Up @@ -75,6 +79,13 @@ export default class BaseGauge {

gauges.push(this);

/**
* Gauges version string
*
* @type {string}
*/
this.version = version;

/**
* Gauge type class
*
Expand Down Expand Up @@ -239,6 +250,15 @@ export default class BaseGauge {
this.animation = null;
}

/**
* Returns gauges version string
*
* @return {string}
*/
static get version() {
return version;
}

/**
* Triggering gauge render on a canvas.
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvas-gauges",
"version": "2.0.7",
"version": "2.0.8",
"description": "Minimalistic HTML5 Canvas Gauges",
"main": "gauge.min.js",
"directories": {
Expand Down

0 comments on commit dd33d29

Please sign in to comment.