• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from __future__ import print_function
2import os
3import re
4
5
6def get_version():
7  node_version_h = os.path.join(
8    os.path.dirname(__file__),
9    '..',
10    'src',
11    'node_version.h')
12
13  f = open(node_version_h)
14
15  regex = '^#define NODE_MODULE_VERSION [0-9]+'
16
17  for line in f:
18    if re.match(regex, line):
19      major = line.split()[2]
20      return major
21
22  raise Exception('Could not find pattern matching %s' % regex)
23
24
25if __name__ == '__main__':
26  print(get_version())
27