about summary refs log tree commit diff
path: root/plugins/notificationsExtension/withSounds.js
blob: 652afd545809a2c8738ea805b15a8136d0000a6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const {withXcodeProject} = require('@expo/config-plugins')
const path = require('path')
const fs = require('fs')

const withSounds = (config, {extensionName, soundFiles}) => {
  // eslint-disable-next-line no-shadow
  return withXcodeProject(config, config => {
    for (const file of soundFiles) {
      const soundPath = path.join(config.modRequest.projectRoot, 'assets', file)

      const targetPath = path.join(
        config.modRequest.platformProjectRoot,
        extensionName,
        file,
      )

      if (!fs.existsSync(path.dirname(targetPath))) {
        fs.mkdirSync(path.dirname(targetPath), {recursive: true})
      }
      fs.copyFileSync(soundPath, targetPath)
    }

    return config
  })
}

module.exports = {withSounds}