about summary refs log tree commit diff
path: root/plugins/notificationsExtension/withSounds.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/notificationsExtension/withSounds.js')
-rw-r--r--plugins/notificationsExtension/withSounds.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/notificationsExtension/withSounds.js b/plugins/notificationsExtension/withSounds.js
new file mode 100644
index 000000000..652afd545
--- /dev/null
+++ b/plugins/notificationsExtension/withSounds.js
@@ -0,0 +1,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}