Skip to content

Commit

Permalink
Include version number in version result.
Browse files Browse the repository at this point in the history
  • Loading branch information
legastero committed Jul 22, 2019
1 parent 4f0c038 commit 9a0e3e0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/build.ts
Expand Up @@ -31,8 +31,8 @@ Child('npm run compile');
Child('npm run compile:module');

// Embed package version into CJS and ES modules
fileReplace('dist/cjs/index.js', '__STANZAJS_VERSION__', Pkg.version);
fileReplace('dist/es/index.js', '__STANZAJS_VERSION__', Pkg.version);
fileReplace('dist/cjs/Constants.js', '__STANZAJS_VERSION__', Pkg.version);
fileReplace('dist/es/Constants.js', '__STANZAJS_VERSION__', Pkg.version);

Child('npm run compile:rollup');

Expand Down
2 changes: 2 additions & 0 deletions src/Constants.ts
Expand Up @@ -7,6 +7,8 @@ import {
NS_SERVER
} from './Namespaces';

export const VERSION = '__STANZAJS_VERSION__';

// ====================================================================
// Frequently Used Values
// ====================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -207,7 +207,7 @@ export interface TransportConfig {

export { Client, Constants, JXT, JID, Namespaces, Stanzas, Jingle, Utils, RTT, LibSASL as SASL };

export const VERSION = '__STANZAJS_VERSION__';
export const VERSION = Constants.VERSION;

import Plugins from './plugins';
export * from './plugins';
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/version.ts
@@ -1,4 +1,5 @@
import { Agent } from '../';
import { VERSION } from '../Constants';
import { NS_VERSION } from '../Namespaces';
import { ReceivedIQGet, SoftwareVersion } from '../protocol';

Expand Down Expand Up @@ -29,7 +30,8 @@ export default function(client: Agent) {
client.on('iq:get:softwareVersion', iq => {
return client.sendIQResult(iq, {
softwareVersion: client.config.softwareVersion || {
name: 'stanzajs.org'
name: 'stanzajs.org',
version: VERSION
}
});
});
Expand Down

0 comments on commit 9a0e3e0

Please sign in to comment.