Skip to content

Commit

Permalink
chore: layer add copy validator image script
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Jan 16, 2024
1 parent da51913 commit ac7456b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions layer/nuxt-config/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { tokenMetadata } from '../../scripts/tokens'
import { bugsnagSourceMaps } from '../../scripts/bugsnag'
import { validatorsLogo } from '../../scripts/validators'

export default {
async 'build:done'() {
await tokenMetadata()
await validatorsLogo()
await bugsnagSourceMaps()
}
}
33 changes: 33 additions & 0 deletions layer/scripts/validators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable no-console */
import path from 'path'
import { copy, removeSync, pathExistsSync, copySync } from 'fs-extra'

export function validatorsLogo(isProduction = false) {
const outputPathPrefix = isProduction ? '.output/public' : 'public'
const validatorsLogoDstDir = path.resolve(
process.cwd(),
`${outputPathPrefix}/vendor/@injectivelabs/sdk-ui-ts`
)
const validatorsLogoSrcDir = path.resolve(
process.cwd(),
'node_modules/@injectivelabs/sdk-ui-ts/dist/validators-logo/images'
)
const outDirPathExist = pathExistsSync(validatorsLogoDstDir)

try {
if (outDirPathExist) {
removeSync(validatorsLogoDstDir)
copySync(validatorsLogoSrcDir, validatorsLogoDstDir, {
overwrite: true
})
} else {
copy(validatorsLogoSrcDir, validatorsLogoDstDir, {
overwrite: true,
errorOnExist: false
})
}
console.log('✔ Successfully copied validator images!')
} catch (e) {
console.log(`Error copying validator images: ${e}`)
}
}

0 comments on commit ac7456b

Please sign in to comment.