import fs from 'fs' import * as dotenv from 'dotenv' dotenv.config() export const copyTypesFileToFrontendPaths = async () => { const localFrontendPath = process.env.FRONTEND_PROJECT_PATHS if (localFrontendPath) { const paths = JSON.parse(localFrontendPath) if (Array.isArray(paths)) { paths.forEach((path) => { if (fs.existsSync(path)) { fs.cpSync('./dist/API/types.ts', `${path}/wappiTypes.ts`, { force: true }) } else { fs.mkdirSync(path, { recursive: true }) fs.cpSync('./dist/API/types.ts', `${path}/wappiTypes.ts`, { force: true }) } }) } else { console.info('Environment variable: FRONTEND_PROJECT_PATHS, is not a Array.') console.info('Make sure it is like this:') console.info('FRONTEND_PROJECT_PATHS=["absolute/path/here", "absolute/path/here"]') } } else { console.info('No FRONTEND_PROJECT_PATHS environment variable.') } }