mirror of
https://github.com/fawazahmed0/exchange-api.git
synced 2025-07-02 03:23:03 +00:00
rename latestDir to rootDir
This commit is contained in:
parent
bcde78805f
commit
7d260f6f0c
@ -44,7 +44,7 @@ for (const [key, value] of Object.entries(allcurr)) { allcurrLower[value.toLower
|
|||||||
|
|
||||||
const dateToday = new Date().toISOString().substring(0, 10)
|
const dateToday = new Date().toISOString().substring(0, 10)
|
||||||
|
|
||||||
const latestDir = path.join(__dirname, 'latest')
|
const rootDir = path.join(__dirname, 'package')
|
||||||
|
|
||||||
begin()
|
begin()
|
||||||
// Begins the program
|
// Begins the program
|
||||||
@ -57,8 +57,8 @@ async function begin() {
|
|||||||
const currJSON = await getCurrencies()
|
const currJSON = await getCurrencies()
|
||||||
// Get & Save All the available currencies in api
|
// Get & Save All the available currencies in api
|
||||||
const availCurrListObj = await getAvailCurrencyJSON(currJSON)
|
const availCurrListObj = await getAvailCurrencyJSON(currJSON)
|
||||||
fs.writeFileSync(path.join(latestDir, 'currencies.min.json'), JSON.stringify(availCurrListObj))
|
fs.writeFileSync(path.join(rootDir, 'currencies.min.json'), JSON.stringify(availCurrListObj))
|
||||||
fs.writeFileSync(path.join(latestDir, 'currencies.json'), JSON.stringify(availCurrListObj, null, indent))
|
fs.writeFileSync(path.join(rootDir, 'currencies.json'), JSON.stringify(availCurrListObj, null, indent))
|
||||||
|
|
||||||
// Generate API files
|
// Generate API files
|
||||||
await generateFiles(currJSON)
|
await generateFiles(currJSON)
|
||||||
@ -68,7 +68,7 @@ async function begin() {
|
|||||||
fs.mkdirSync(dateDir, {
|
fs.mkdirSync(dateDir, {
|
||||||
recursive: true
|
recursive: true
|
||||||
})
|
})
|
||||||
fs.copySync(latestDir, dateDir)
|
fs.copySync(rootDir, dateDir)
|
||||||
|
|
||||||
// Close the browser
|
// Close the browser
|
||||||
// await browser.close()
|
// await browser.close()
|
||||||
@ -181,12 +181,12 @@ function sortObjByKeys(obj) {
|
|||||||
|
|
||||||
// Generates the api files
|
// Generates the api files
|
||||||
async function generateFiles(googBingCurrJSON) {
|
async function generateFiles(googBingCurrJSON) {
|
||||||
const currenciesDir = path.join(latestDir, 'currencies')
|
const currenciesDir = path.join(rootDir, 'currencies')
|
||||||
for (const [fromKey, fromValue] of Object.entries(googBingCurrJSON)) {
|
for (const [fromKey, fromValue] of Object.entries(googBingCurrJSON)) {
|
||||||
const tempObj = {}
|
const tempObj = {}
|
||||||
tempObj['date'] = dateToday;
|
tempObj['date'] = dateToday;
|
||||||
tempObj[fromKey] = {}
|
tempObj[fromKey] = {}
|
||||||
const fromKeyDir = path.join(latestDir, 'currencies', fromKey)
|
const fromKeyDir = path.join(rootDir, 'currencies', fromKey)
|
||||||
fs.mkdirSync(fromKeyDir, {
|
fs.mkdirSync(fromKeyDir, {
|
||||||
recursive: true
|
recursive: true
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user