about summary refs log tree commit diff
path: root/plugins/shareExtension/withExtensionViewController.js
blob: cd29bea7dac9622aecf45de765ef2b17457f75b5 (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
28
29
30
31
const {withXcodeProject} = require('@expo/config-plugins')
const path = require('path')
const fs = require('fs')

const withExtensionViewController = (
  config,
  {controllerName, extensionName},
) => {
  // eslint-disable-next-line no-shadow
  return withXcodeProject(config, config => {
    const controllerPath = path.join(
      config.modRequest.projectRoot,
      'modules',
      extensionName,
      `${controllerName}.swift`,
    )

    const targetPath = path.join(
      config.modRequest.platformProjectRoot,
      extensionName,
      `${controllerName}.swift`,
    )

    fs.mkdirSync(path.dirname(targetPath), {recursive: true})
    fs.copyFileSync(controllerPath, targetPath)

    return config
  })
}

module.exports = {withExtensionViewController}