Skip to content

Commit

Permalink
Showing 3 changed files with 29 additions and 29 deletions.
21 changes: 2 additions & 19 deletions layer/scripts/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
/* eslint-disable no-console */
import path from 'path'
import { copy, removeSync, pathExistsSync, readdir } from 'fs-extra'

async function copyInChunks(
sourceDir: string,
destDir: string,
chunkSize = 25
) {
const files = await readdir(sourceDir)

for (let i = 0; i < files.length; i += chunkSize) {
const chunk = files.slice(i, i + chunkSize)

for (const file of chunk) {
await copy(path.join(sourceDir, file), path.join(destDir, file), {
overwrite: true
})
}
}
}
import { removeSync, pathExistsSync} from 'fs-extra'
import { copyInChunks } from '../utils/scripts'

export async function tokenMetadata(isProduction = false) {
const outputPathPrefix = isProduction ? '.output/public' : 'public'
16 changes: 6 additions & 10 deletions layer/scripts/validators.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable no-console */
import path from 'path'
import { copy, removeSync, pathExistsSync, copySync } from 'fs-extra'
import { removeSync, pathExistsSync} from 'fs-extra'
import { copyInChunks } from '../utils/scripts'

export function validatorsLogo(isProduction = false) {
export async function validatorsLogo(isProduction = false) {
const outputPathPrefix = isProduction ? '.output/public' : 'public'
const validatorsLogoDstDir = path.resolve(
process.cwd(),
@@ -17,15 +18,10 @@ export function validatorsLogo(isProduction = false) {
try {
if (outDirPathExist) {
removeSync(validatorsLogoDstDir)
copySync(validatorsLogoSrcDir, validatorsLogoDstDir, {
overwrite: true
})
} else {
copy(validatorsLogoSrcDir, validatorsLogoDstDir, {
overwrite: true,
errorOnExist: false
})
}

await copyInChunks(validatorsLogoSrcDir, validatorsLogoDstDir)

console.log('✔ Successfully copied validator images!')
} catch (e) {
console.log(`Error copying validator images: ${e}`)
21 changes: 21 additions & 0 deletions layer/utils/scripts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { copy, readdir } from 'fs-extra'
import path from 'path'


export const copyInChunks = async (
sourceDir: string,
destDir: string,
chunkSize = 25
) => {
const files = await readdir(sourceDir)

for (let i = 0; i < files.length; i += chunkSize) {
const chunk = files.slice(i, i + chunkSize)

for (const file of chunk) {
await copy(path.join(sourceDir, file), path.join(destDir, file), {
overwrite: true
})
}
}
}

0 comments on commit 6fd6c91

Please sign in to comment.