forked from EdgeApp/edge-react-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy-plugin.js
34 lines (28 loc) · 877 Bytes
/
copy-plugin.js
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
32
33
34
/* eslint-disable flowtype/require-valid-file-annotation */
const fs = require('fs')
const path = require('path')
const { plugins } = require('./package.json')
const androidDir = './android/app/src/main/assets/plugins/'
const iosDir = './ios/plugins/'
const platforms = [androidDir, iosDir]
platforms.forEach(platform => {
if (!fs.existsSync(platform)) {
fs.mkdirSync(platform)
}
})
function copyAssets(plugin) {
const manifest = require(`./node_modules/${plugin}/manifest.json`)
platforms.forEach(platformDir => {
const pluginDir = path.join(platformDir, manifest.pluginId)
if (!fs.existsSync(pluginDir)) {
fs.mkdirSync(pluginDir)
}
fs.copyFile(`./node_modules/${plugin}/target/index.html`, `${pluginDir}/index.html`, () => {})
})
return manifest
}
if (plugins) {
plugins.forEach(function (plugin) {
copyAssets(plugin)
})
}