From a76fd811ed81f014d17c39b6eaa389cd4fd29e1b Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 17 Jan 2014 01:20:30 -0500 Subject: [PATCH] Added version.js --- .gitignore | 1 + configure.ac | 9 ++++++++- index.js | 7 ++++--- src/version.js.in | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 src/version.js.in diff --git a/.gitignore b/.gitignore index 0a5fe12..85310f7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ configure Makefile.in # generated by configure +src/version.js config.* Makefile package.json diff --git a/configure.ac b/configure.ac index 6b40a60..9024783 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,13 @@ AC_INIT([liza], [0.0.1-dev], [dev@lovullo.com]) AC_CONFIG_AUX_DIR([tools]) AM_INIT_AUTOMAKE([foreign]) +# provide more granular version numbers based on the above AC_INIT line +m4_define([ver_split], m4_split(m4_translit(AC_PACKAGE_VERSION, [-], [.]), [\.])) +AC_SUBST(MAJOR, m4_argn(1, ver_split)) +AC_SUBST(MINOR, m4_argn(2, ver_split)) +AC_SUBST(REV, m4_argn(3, ver_split)) +AC_SUBST(SUFFIX, m4_argn(4, ver_split)) + # generate files from their *.in counterparts -AC_CONFIG_FILES([Makefile doc/Makefile package.json]) +AC_CONFIG_FILES([Makefile doc/Makefile package.json src/version.js]) AC_OUTPUT diff --git a/index.js b/index.js index 58d93d7..184680a 100644 --- a/index.js +++ b/index.js @@ -19,8 +19,9 @@ * along with this program. If not, see . */ -// as soon as we have something to export, this will be replaced with a -// module.exports line containing an object that itself contains classes +// as soon as we have something useful to export, this will contain classes // that represent common, viable entry points for the framework (e.g. // facades). -throw Error( "You're too early! Check back soon." ); +module.exports = { + version: require( __dirname + '/src/version' ) +}; diff --git a/src/version.js.in b/src/version.js.in new file mode 100644 index 0000000..1bd6487 --- /dev/null +++ b/src/version.js.in @@ -0,0 +1,43 @@ +/** + * Provides version information + * + * Copyright (C) 2014 LoVullo Associates, Inc. + * + * This file is part of liza. + * + * liza is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Taken from GNU ease.js. + */ + +var major = @MAJOR@, + minor = @MINOR@, + rev = @REV@, + suffix = '@SUFFIX@', + + version = [ major, minor, rev, suffix ]; + +version.major = major; +version.minor = minor; +version.rev = rev; +version.suffix = suffix; + +version.toString = function() +{ + return this.join( '.' ) + .replace( /\.([^.]+)$/, '-$1' ) + .replace( /-$/, '' ); +}; + +module.exports = version;