Repository: cypress-io/cypress
File: scripts/after-pack-hook.js (JavaScript)

Code before:

    const distNodeModules = path.join(params.packager.info._appDir, 'node_modules')
    const appNodeModules = path.join(outputFolder, 'node_modules')

    console.log('copying ', distNodeModules, ' to', appNodeModules)

    await fs.copy(distNodeModules, appNodeModules)

    console.log('all node_modules subfolders copied to', outputFolder)

    const exePathPerPlatform = {
      darwin: join(params.appOutDir, 'Cypress.app', 'Contents', 'MacOS', 'Cypress'),
      linux: join(params.appOutDir, 'Cypress'),
      win32: join(params.appOutDir, 'Cypress.exe'),
    }

    if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) {
      const binaryByteNodeEntryPointSource = await getBinaryByteNodeEntryPointSource()
      const binaryEntryPointSource = await getBinaryEntryPointSource()
      const encryptionFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/encryption.ts')
      const encryptionFileSource = await getEncryptionFileSource(encryptionFilePath)
      const cloudEnvironmentFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/environment.ts')
      const cloudEnvironmentFileSource = await getCloudEnvironmentFileSource(cloudEnvironmentFilePath)

      await Promise.all([
        fs.writeFile(path.join(outputFolder, 'index.js'), binaryByteNodeEntryPointSource),
        fs.writeFile(encryptionFilePath, encryptionFileSource),
        fs.writeFile(cloudEnvironmentFilePath, cloudEnvironmentFileSource),
      ])

      // Remove local protocol env
      const cloudApiFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/api/index.ts')
      const cloudApiFileSource = await getProtocolFileSource(cloudApiFilePath)
      const cloudProtocolFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/protocol.ts')
      const cloudProtocolFileSource = await getProtocolFileSource(cloudProtocolFilePath)

      await Promise.all([
        fs.writeFile(cloudApiFilePath, cloudApiFileSource),
        fs.writeFile(cloudProtocolFilePath, cloudProtocolFileSource),
      ])

      // Remove local studio env
      const reportStudioErrorPath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/api/studio/report_studio_error.ts')
      const reportStudioErrorFileSource = await getStudioFileSource(reportStudioErrorPath)
      const StudioLifecycleManagerPath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/studio/StudioLifecycleManager.ts')
      const StudioLifecycleManagerFileSource = await getStudioFileSource(StudioLifecycleManagerPath)
      const studioProtocolFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/protocol.ts')
      const studioProtocolFileSource = await getStudioFileSource(studioProtocolFilePath)
      const studioPath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/studio/studio.ts')
      const studioPathFileSource = await getStudioFileSource(studioPath)


Review comment (suggestion):
```suggestion
        fs.writeFile(path.join(outputFolder, 'index.js'), binaryEntryPointSource),
```

Code after:

    const distNodeModules = path.join(params.packager.info._appDir, 'node_modules')
    const appNodeModules = path.join(outputFolder, 'node_modules')

    console.log('copying ', distNodeModules, ' to', appNodeModules)

    await fs.copy(distNodeModules, appNodeModules)

    console.log('all node_modules subfolders copied to', outputFolder)

    const exePathPerPlatform = {
      darwin: join(params.appOutDir, 'Cypress.app', 'Contents', 'MacOS', 'Cypress'),
      linux: join(params.appOutDir, 'Cypress'),
      win32: join(params.appOutDir, 'Cypress.exe'),
    }

    if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) {
      const binaryByteNodeEntryPointSource = await getBinaryByteNodeEntryPointSource()
      const binaryEntryPointSource = await getBinaryEntryPointSource()
      const encryptionFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/encryption.ts')
      const encryptionFileSource = await getEncryptionFileSource(encryptionFilePath)
      const cloudEnvironmentFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/environment.ts')
      const cloudEnvironmentFileSource = await getCloudEnvironmentFileSource(cloudEnvironmentFilePath)

      await Promise.all([
        fs.writeFile(path.join(outputFolder, 'index.js'), binaryEntryPointSource),
        fs.writeFile(encryptionFilePath, encryptionFileSource),
        fs.writeFile(cloudEnvironmentFilePath, cloudEnvironmentFileSource),
      ])

      // Remove local protocol env
      const cloudApiFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/api/index.ts')
      const cloudApiFileSource = await getProtocolFileSource(cloudApiFilePath)
      const cloudProtocolFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/protocol.ts')
      const cloudProtocolFileSource = await getProtocolFileSource(cloudProtocolFilePath)

      await Promise.all([
        fs.writeFile(cloudApiFilePath, cloudApiFileSource),
        fs.writeFile(cloudProtocolFilePath, cloudProtocolFileSource),
      ])

      // Remove local studio env
      const reportStudioErrorPath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/api/studio/report_studio_error.ts')
      const reportStudioErrorFileSource = await getStudioFileSource(reportStudioErrorPath)
      const StudioLifecycleManagerPath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/studio/StudioLifecycleManager.ts')
      const StudioLifecycleManagerFileSource = await getStudioFileSource(StudioLifecycleManagerPath)
      const studioProtocolFilePath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/protocol.ts')
      const studioProtocolFileSource = await getStudioFileSource(studioProtocolFilePath)
      const studioPath = path.join(CY_ROOT_DIR, 'packages/server/lib/cloud/studio/studio.ts')
      const studioPathFileSource = await getStudioFileSource(studioPath)