forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-badges.js
35 lines (23 loc) · 1.03 KB
/
update-badges.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
// ---------------------------------------------------------------------------
// Usage:
//
// npm run update-badges
// ---------------------------------------------------------------------------
"use strict";
const fs = require ('fs')
const ccxt = require ('../ccxt')
const log = require ('ololog')
const ansi = require ('ansicolor').nice
//-----------------------------------------------------------------------------
function updateExchangeCount (fileName) {
log.bright.cyan ('Updating exchange count →', fileName.yellow)
let oldContent = fs.readFileSync (fileName, 'utf8')
let newContent =
oldContent.replace (/shields\.io\/badge\/exchanges\-[0-9a-z]+\-blue/g, 'shields.io/badge/exchanges-' + ccxt.exchanges.length + '-blue')
fs.truncateSync (fileName)
fs.writeFileSync (fileName, newContent)
}
updateExchangeCount ('./README.md')
updateExchangeCount ('./python/README.md')
log.bright.green ('Badges updated successfully.')
//-----------------------------------------------------------------------------