forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvss.js
58 lines (45 loc) · 2.35 KB
/
vss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"use strict";
const fs = require ('fs')
const ccxt = require ('./ccxt')
const countries = require ('./countries')
const asTable = require ('as-table')
const util = require ('util')
//-----------------------------------------------------------------------------
let packageJSON = fs.readFileSync ('./package.json', 'utf8')
let config = JSON.parse (packageJSON);
let version = config.version
//-----------------------------------------------------------------------------
console.log ('Old version: ', version)
let [ major, minor, patch ] = version.split ('.')
patch = (parseInt (patch) + 1).toString ()
version = [ major, minor, patch ].join ('.')
console.log ('New version: ', version)
//-----------------------------------------------------------------------------
console.log ('Single-sourcing version', version, './package.json → ./ccxt.js')
let ccxtjsFilename = './ccxt.js'
let ccxtjs = fs.readFileSync (ccxtjsFilename, 'utf8')
let ccxtjsParts = ccxtjs.split (/var version \= \'[^\']+\'/)
let ccxtjsNewContent = ccxtjsParts[0] + "var version = '" + version + "'" + ccxtjsParts[1]
fs.truncateSync (ccxtjsFilename)
fs.writeFileSync (ccxtjsFilename, ccxtjsNewContent)
console.log ('Done.')
//-----------------------------------------------------------------------------
console.log ('Single-sourcing version', version, './package.json → ./ccxt/__init__.py')
let ccxtpyFilename = './ccxt/__init__.py'
let ccxtpy = fs.readFileSync (ccxtpyFilename, 'utf8')
let ccxtpyParts = ccxtpy.split (/\_\_version\_\_ \= \'[^\']+\'/)
let ccxtpyNewContent = ccxtpyParts[0] + "__version__ = '" + version + "'" + ccxtpyParts[1]
fs.truncateSync (ccxtpyFilename)
fs.writeFileSync (ccxtpyFilename, ccxtpyNewContent)
console.log ('Done.')
//-----------------------------------------------------------------------------
console.log ('Single-sourcing version', version, './package.json → ./ccxt.php')
let ccxtphpFilename = './ccxt.php'
let ccxtphp = fs.readFileSync (ccxtphpFilename, 'utf8')
let ccxtphpParts = ccxtphp.split (/\$version \= \'[^\']+\'/)
let ccxtphpNewContent = ccxtphpParts[0] + '$version' + " = '" + version + "'" + ccxtphpParts[1]
fs.truncateSync (ccxtphpFilename)
fs.writeFileSync (ccxtphpFilename, ccxtphpNewContent)
console.log ('Done.')
//-----------------------------------------------------------------------------
console.log ('Version single-sourced successfully.')