File tree 7 files changed +64
-2
lines changed
7 files changed +64
-2
lines changed Original file line number Diff line number Diff line change 1
1
SHA := $(shell git rev-parse HEAD)
2
2
THIS_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
3
- VERSION_REGEX = [0-9]*\.[0-9]*\.[0-9]*[^\" ]*
3
+ VERSION_REGEX = [0-9][0-9] *\.[0-9][0-9] *\.[0-9] [0-9]*[^\" ]*
4
4
VERSION := $(shell npm ls | grep "swig@" | grep -Eo "${VERSION_REGEX}" -m 1)
5
5
6
6
TMP = 'tmp'
14
14
@cp scripts/githooks/* .git/hooks/
15
15
@chmod -R +x .git/hooks/
16
16
17
+ .INTERMEDIATE version : \
18
+ browser/comments.js \
19
+ docs/index.json
20
+
21
+ version :
22
+ @sed -i.bak ' s/${VERSION_REGEX}/${VERSION}/' lib/swig.js
23
+ @rm lib/swig.js.bak
24
+
17
25
browser/comments.js : FORCE
18
26
@sed -i.bak ' s/v${VERSION_REGEX}/v${VERSION}/' $@
19
27
@rm $@ .bak
@@ -156,7 +164,7 @@ docs: build build-docs
156
164
157
165
FORCE :
158
166
159
- .PHONY : all \
167
+ .PHONY : all version \
160
168
build build-docs \
161
169
test test-browser lint coverage \
162
170
docs/index.json docs gh-pages
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ var command,
16
16
' $0 render [files] [options]\n'
17
17
)
18
18
. describe ( {
19
+ v : 'Show the Swig version number.' ,
19
20
o : 'Output location.' ,
20
21
h : 'Show this help screen.' ,
21
22
j : 'Variable context as a JSON file.' ,
@@ -25,6 +26,7 @@ var command,
25
26
'wrap-end' : 'Template wrapper end for "compile".' ,
26
27
'method-name' : 'Method name to set template to and run from.'
27
28
} )
29
+ . alias ( 'v' , 'version' )
28
30
. alias ( 'o' , 'output' )
29
31
. default ( 'o' , 'stdout' )
30
32
. alias ( 'h' , 'help' )
@@ -35,6 +37,10 @@ var command,
35
37
. default ( 'wrap-end' , ';' )
36
38
. default ( 'method-name' , 'tpl' )
37
39
. check ( function ( argv ) {
40
+ if ( argv . v ) {
41
+ return ;
42
+ }
43
+
38
44
if ( ! argv . _ . length ) {
39
45
throw new Error ( '' ) ;
40
46
}
@@ -62,6 +68,11 @@ var command,
62
68
files ,
63
69
fn ;
64
70
71
+ if ( argv . v ) {
72
+ console . log ( require ( '../package' ) . version ) ;
73
+ process . exit ( 0 ) ;
74
+ }
75
+
65
76
if ( argv . j ) {
66
77
ctx = JSON . parse ( fs . readFileSync ( argv . j , 'utf8' ) ) ;
67
78
} else if ( argv . c ) {
Original file line number Diff line number Diff line change @@ -42,6 +42,21 @@ <h3>Examples</h3>
42
42
</ section >
43
43
{% endfor %}
44
44
45
+ {% for prop in properties %}
46
+ < section id ="{{ prop.name }} " class ="doc ">
47
+ < h2 > swig.{{ prop.name }}</ h2 >
48
+
49
+ < p > {{ prop.description|replace('\n', '</ p > < p > ')|raw }}</ p >
50
+
51
+ {% if prop.examples.length %}
52
+ < h3 > Examples</ h3 >
53
+ {% for example in prop.examples %}
54
+ < pre > < code data-language ="js "> {{ example }}</ code > </ pre >
55
+ {% endfor %}
56
+ {% endif %}
57
+ </ section >
58
+ {% endfor %}
59
+
45
60
{% for fn in functions %}
46
61
{% if fn.access !== "private" %}
47
62
< section id ="{{ fn.name }} " class ="doc ">
@@ -104,6 +119,9 @@ <h3>Examples</h3>
104
119
{% for def in typedefs %}
105
120
< li > < a href ="#{{ def.name }} "> Object: {{ def.name }}</ a > </ li >
106
121
{% endfor %}
122
+ {% for prop in properties %}
123
+ < li > < a href ="#{{ prop.name }} "> swig.{{ prop.name }}</ a > </ li >
124
+ {% endfor %}
107
125
{% for fn in functions %}
108
126
{% if fn.access !== "private" %}
109
127
< li >
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ <h2>Usage</h2>
21
21
22
22
< h3 > Options</ h3 >
23
23
< pre >
24
+ -v, --version Show the Swig version number.
24
25
-o, --output Output location. [default: "stdout"]
25
26
-h, --help Show this help screen.
26
27
-j, --json Variable context as a JSON file.
Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ var fs = require('fs'),
6
6
parser = require ( './parser' ) ,
7
7
dateformatter = require ( './dateformatter' ) ;
8
8
9
+ /**
10
+ * Swig version number as a string.
11
+ * @example
12
+ * if (swig.version === "1.0.0-pre3") { ... }
13
+ *
14
+ * @type {String }
15
+ */
16
+ exports . version = "1.0.0-pre3" ;
17
+
9
18
/**
10
19
* Swig Options Object. This object can be passed to many of the API-level Swig methods to control various aspects of the engine. All keys are optional.
11
20
* @typedef {Object } SwigOpts
Original file line number Diff line number Diff line change @@ -12,6 +12,12 @@ function resetOptions() {
12
12
swig . invalidateCache ( ) ;
13
13
}
14
14
15
+ describe ( 'version' , function ( ) {
16
+ it ( 'is 1.0.0-pre3' , function ( ) {
17
+ expect ( swig . version ) . to . equal ( '1.0.0-pre3' ) ;
18
+ } ) ;
19
+ } ) ;
20
+
15
21
describe ( 'options' , function ( ) {
16
22
beforeEach ( resetOptions ) ;
17
23
afterEach ( resetOptions ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,15 @@ var casefiles = fs.readdirSync(__dirname + '/cases/'),
21
21
return f . split ( '.' ) [ 0 ] ;
22
22
} ) ;
23
23
24
+ describe ( 'bin/swig -v' , function ( ) {
25
+ it ( 'shows the version number' , function ( done ) {
26
+ exec ( bin + ' -v' , function ( err , stdout , stderr ) {
27
+ expect ( ( / ^ \d + \. \d + \. \d + / ) . test ( stdout ) ) . to . equal ( true ) ;
28
+ done ( ) ;
29
+ } ) ;
30
+ } ) ;
31
+ } ) ;
32
+
24
33
describe ( 'bin/swig render' , function ( ) {
25
34
_ . each ( cases , function ( files , c ) {
26
35
var test = _ . find ( files , isTest ) ,
You can’t perform that action at this time.
0 commit comments