diff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.ts index c5d153ec..54dad1a8 100644 --- a/apps/desktop/forge.config.ts +++ b/apps/desktop/forge.config.ts @@ -175,39 +175,45 @@ const config: ForgeConfig = { }); for (const nodeModule of nodeModules) { - if (nodeModule.isDirectory() && nodeModule.name !== 'node_modules') { - const files = await fs.readdir( - path.join(nodeModulesPath, nodeModule.name), - { - withFileTypes: true, + if (!nodeModule.isDirectory()) { + continue; + } + + if (nodeModule.name === 'node_modules') { + continue; + } + + const files = await fs.readdir( + path.join(nodeModulesPath, nodeModule.name), + { + withFileTypes: true, + } + ); + + if (files.length === 0) { + await fs.rmdir(path.join(nodeModulesPath, nodeModule.name)); + } else { + for (const file of files) { + if (!file.isFile()) { + continue; } - ); - if (files.length === 0) { - await fs.rmdir(path.join(nodeModulesPath, nodeModule.name)); - } else { - for (const file of files) { - if (!file.isFile()) { - continue; - } + const shouldDelete = + file.name === 'LICENSE' || + file.name.endsWith('.md') || + file.name.endsWith('.txt') || + file.name.endsWith('.lock') || + file.name.endsWith('.yaml') || + file.name.endsWith('.yml') || + file.name.endsWith('.gitignore') || + file.name.endsWith('.npmignore') || + file.name.endsWith('.npmrc') || + file.name.endsWith('.npm'); - const shouldDelete = - file.name === 'LICENSE' || - file.name.endsWith('.md') || - file.name.endsWith('.txt') || - file.name.endsWith('.lock') || - file.name.endsWith('.yaml') || - file.name.endsWith('.yml') || - file.name.endsWith('.gitignore') || - file.name.endsWith('.npmignore') || - file.name.endsWith('.npmrc') || - file.name.endsWith('.npm'); - - if (shouldDelete) { - await fs.rm( - path.join(nodeModulesPath, nodeModule.name, file.name) - ); - } + if (shouldDelete) { + await fs.rm( + path.join(nodeModulesPath, nodeModule.name, file.name) + ); } } } diff --git a/scripts/src/postinstall/index.ts b/scripts/src/postinstall/index.ts index 33e32800..d1666943 100644 --- a/scripts/src/postinstall/index.ts +++ b/scripts/src/postinstall/index.ts @@ -2,41 +2,33 @@ import path from 'path'; import fs from 'fs'; const copyEmojisDb = () => { - const sourceEmojisDbPath = path.resolve( - 'scripts', - 'src', - 'emojis', - 'emojis.db' - ); - - if (!fs.existsSync(sourceEmojisDbPath)) { + const sourcePath = path.resolve('scripts', 'src', 'emojis', 'emojis.db'); + if (!fs.existsSync(sourcePath)) { return; } - const targetEmojisDbPath = path.resolve( - 'apps', - 'desktop', - 'assets', - 'emojis.db' - ); + const targetDir = path.resolve('apps', 'desktop', 'assets'); + if (!fs.existsSync(targetDir)) { + return; + } - fs.copyFileSync(sourceEmojisDbPath, targetEmojisDbPath); + const targetPath = path.resolve(targetDir, 'emojis.db'); + fs.copyFileSync(sourcePath, targetPath); }; const copyIconsDb = () => { - const sourceIconsDbPath = path.resolve('scripts', 'src', 'icons', 'icons.db'); - if (!fs.existsSync(sourceIconsDbPath)) { + const sourcePath = path.resolve('scripts', 'src', 'icons', 'icons.db'); + if (!fs.existsSync(sourcePath)) { return; } - const targetIconsDbPath = path.resolve( - 'apps', - 'desktop', - 'assets', - 'icons.db' - ); + const targetDir = path.resolve('apps', 'desktop', 'assets'); + if (!fs.existsSync(targetDir)) { + return; + } - fs.copyFileSync(sourceIconsDbPath, targetIconsDbPath); + const targetPath = path.resolve(targetDir, 'icons.db'); + fs.copyFileSync(sourcePath, targetPath); }; const execute = () => {