Skip to content

Commit

Permalink
make WaveSurfer.VERSION available (katspaugh#1431)
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed Aug 20, 2018
1 parent e99d724 commit ac84115
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = {
Uint32Array: true,
Promise: true,
Uint8Array: true,
ArrayBuffer: true
ArrayBuffer: true,
__VERSION__: true
},
env: {
browser: true,
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ wavesurfer.js changelog
------------------

- Add wavesurfer.js logo, created by @entonbiba (#1409)
- Library version number is now available as `WaveSurfer.VERSION` (#1430)
- Fix `setSinkId` that used deprecated API (#1428)
- Set `isReady` attribute to false when emptying wavesufer (#1396, #1403)

Expand Down
7 changes: 6 additions & 1 deletion build-config/fragments/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const jsBannerPlugin = new webpack.BannerPlugin({
test: /\.js$/
});

// inject JS version number
const jsVersionPlugin = new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pckg.version)
});

module.exports = {
context: rootDir,
mode: 'development',
Expand Down Expand Up @@ -50,5 +55,5 @@ module.exports = {
}
]
},
plugins: [jsBannerPlugin]
plugins: [jsBannerPlugin, jsVersionPlugin]
};
9 changes: 9 additions & 0 deletions spec/wavesurfer.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env jasmine */

import TestHelpers from './test-helpers.js';
import WaveSurfer from '../src/wavesurfer.js';

/** @test {WaveSurfer} */
describe('WaveSurfer/playback:', function() {
Expand Down Expand Up @@ -34,6 +35,14 @@ describe('WaveSurfer/playback:', function() {
expect(wavesurfer.isReady).toBeFalse();
});

/**
* @test {WaveSurfer#VERSION}
*/
it('should have version number', function() {
let version = require('../package.json').version;
expect(WaveSurfer.VERSION).toEqual(version);
});

/**
* @test {WaveSurfer#play}
* @test {WaveSurfer#isPlaying}
Expand Down
10 changes: 10 additions & 0 deletions src/wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ export default class WaveSurfer extends util.Observer {
return wavesurfer.init();
}

/**
* The library version number is available as a static property of the
* WaveSurfer class
*
* @type {String}
* @example
* console.log('Using wavesurfer.js ' + WaveSurfer.VERSION);
*/
static VERSION = __VERSION__;

/**
* Functions in the `util` property are available as a prototype property to
* all instances
Expand Down

0 comments on commit ac84115

Please sign in to comment.