Skip to content

Commit

Permalink
Merge pull request ccxt#3397 from munrocket/master
Browse files Browse the repository at this point in the history
config for custom bundles including small amount of exchanges
  • Loading branch information
kroitor authored Jul 15, 2018
2 parents c3c24f2 + a3e627a commit 8d5e4bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions exchanges.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -----------------------------------------------------------------------------
# You can create a custom bundle of CCXT including only the exchanges you need.
# Add or uncomment exchanges' ids below and launch `npm run build`.
# -----------------------------------------------------------------------------

# binance
# huobi
# kraken
10 changes: 9 additions & 1 deletion export-exchanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ function replaceInFile (filename, regex, replacement) {

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

const includedIds = fs.readFileSync ('exchanges.cfg')
.toString () // Buffer → String
.split ('\n') // String → Array
.map (line => line.split ('#')[0].trim ()) // trim comments
.filter (exchange => exchange); // filter empty lines

const isIncluded = (id) => ((includedIds.length === 0) || includedIds.includes (id))
try {

exchanges = require ('./config')
exchanges = require ('./config').ids.filter (isIncluded)

} catch (e) {

Expand All @@ -47,6 +54,7 @@ try {
const ids = fs.readdirSync ('./js/')
.filter (file => file.includes ('.js'))
.map (file => file.slice (0, -3))
.filter (isIncluded);

const pad = function (string, n) {
return (string + ' '.repeat (n)).slice (0, n)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"readme": "README.md",
"scripts": {
"build": "npm run export-exchanges && npm run vss && npm run pandoc-all && npm run check-js-syntax && npm run transpile && npm run qa && npm run update-badges && npm run browserify",
"build": "npm run export-exchanges && npm run vss && npm run check-js-syntax && npm run transpile && npm run qa && npm run pandoc-all && npm run update-badges && npm run browserify",
"test": "npm run build && node run-tests",
"fast-test": "node run-tests --js",
"test-base": "npm run test-js-base && npm run test-python-base && npm run test-php-base",
Expand Down
5 changes: 4 additions & 1 deletion transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,11 @@ function transpileDerivedExchangeFile (folder, filename) {

function transpileDerivedExchangeFiles (folder, pattern = '.js') {

// exchanges.json accounts for ids included in exchanges.cfg
const ids = require ('./exchanges.json').ids;

const classNames = fs.readdirSync (folder)
.filter (file => file.includes (pattern))
.filter (file => file.includes (pattern) && ids.includes (path.basename (file, pattern)))
.map (file => transpileDerivedExchangeFile (folder, file))

if (classNames.length === 0)
Expand Down

0 comments on commit 8d5e4bc

Please sign in to comment.