Skip to content

Commit

Permalink
vss paths + refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Oct 29, 2017
1 parent d1b1e72 commit 948210b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
2 changes: 1 addition & 1 deletion convert-md-2-rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
echo "Converting .md → .rst..."
pandoc --wrap=preserve --columns=10000 --from=markdown --to=rst --output=README.rst README.md
pandoc --wrap=preserve --columns=10000 --from=markdown --to=rst --output=python/README.rst README.md
pandoc --wrap=preserve --columns=10000 --from=markdown --to=rst --output=doc/README.rst README.md
pandoc --wrap=preserve --columns=10000 --from=markdown --to=rst --output=doc/manual.rst ccxt.wiki/Manual.md
pandoc --wrap=preserve --columns=10000 --from=markdown --to=rst --output=doc/install.rst ccxt.wiki/Install.md
Expand Down
4 changes: 2 additions & 2 deletions export-exchanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ try {
}
let idString = " '" + ids.join ("',\n '") + "',"

log.bright.cyan ('Exporting exchanges → ./ccxt/exchanges.py'.yellow)
log.bright.cyan ('Exporting exchanges → ./python/ccxt/exchanges.py'.yellow)

let ccxtpyFilename = './ccxt/exchanges.py'
let ccxtpyFilename = './python/ccxt/exchanges.py'
let ccxtpy = fs.readFileSync (ccxtpyFilename, 'utf8')
let ccxtpyParts = ccxtpy.split (/exchanges \= \[[^\]]+\]/)
let ccxtpyNewContent = ccxtpyParts[0] + "exchanges = [\n" + idString + "\n]" + ccxtpyParts[1]
Expand Down
37 changes: 11 additions & 26 deletions vss.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,20 @@ let [ major, minor, patch ] = version.split ('.')
version = [ major, minor, patch ].join ('.')
log.bright ('New version: '.cyan, version)

//-----------------------------------------------------------------------------

log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt.js'.yellow)
let ccxtjsFilename = './ccxt.js'
let ccxtjs = fs.readFileSync (ccxtjsFilename, 'utf8')
let ccxtjsParts = ccxtjs.split (/const version \= \'[^\']+\'/)
let ccxtjsNewContent = ccxtjsParts[0] + "const version = '" + version + "'" + ccxtjsParts[1]
fs.truncateSync (ccxtjsFilename)
fs.writeFileSync (ccxtjsFilename, ccxtjsNewContent)

//-----------------------------------------------------------------------------

log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt/version.py'.yellow)
let ccxtpyFilename = './ccxt/version.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)
function vss (filename, regex, replacement) {
log.bright.cyan ('Single-sourcing version', version, './package.json → ' + filename.yellow)
let oldContent = fs.readFileSync (filename, 'utf8')
let parts = oldContent.split (regex)
let newContent = parts[0] + replacement + version + "'" + parts[1]
fs.truncateSync (filename)
fs.writeFileSync (filename, newContent)
}

//-----------------------------------------------------------------------------

log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt.php'.yellow)
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)
vss ('./ccxt.js', /const version \= \'[^\']+\'/, "const version = '")
vss ('./python/ccxt/version.py', /\_\_version\_\_ \= \'[^\']+\'/, "__version__ = '")
vss ('./ccxt.php', /\$version \= \'[^\']+\'/, "$version = '")

//-----------------------------------------------------------------------------

Expand Down

0 comments on commit 948210b

Please sign in to comment.