git @ Cat's Eye Technologies Lexeduct / 0.1-2016.0315
Don't require node to build; fall back to python if node missing. Chris Pressey 5 years ago
2 changed file(s) with 29 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
00 #!/bin/sh
11
2 NODE="node"
23 cd src
3 node gen-lexeduct-transformers.js >../demo/lexeduct-transformers.js
4 if [ x`which $NODE` != x ]; then
5 $NODE gen-lexeduct-transformers.js >../demo/lexeduct-transformers.js
6 else
7 python gen-lexeduct-transformers.py >../demo/lexeduct-transformers.js
8 fi
0 #!/usr/bin/env python
1
2 import os
3 import sys
4
5 def write(s):
6 sys.stdout.write(s + "\n")
7
8 def main(args):
9 write("module = {};")
10 write("transformer = {};")
11 dirname = "transformers"
12 for root, dirnames, filenames in os.walk(dirname):
13 dirnames[:] = []
14 filenames.sort()
15 for filename in filenames:
16 transformer_name = filename.split('.js')[0]
17 with open(os.path.join(dirname, filename)) as f:
18 write(f.read())
19 write("transformer['%s'] = module.exports;" % transformer_name)
20
21 if __name__ == '__main__':
22 main(sys.argv[1:])