forked from EdgeApp/edge-react-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-plugin.js
49 lines (41 loc) · 1.26 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* eslint-disable flowtype/require-valid-file-annotation */
const fs = require('fs')
const path = require('path')
const {plugins} = require('./package.json')
const pluginsFile = './src/assets/plugins.json'
const androidDir = './android/app/src/main/assets/plugins/'
const iosDir = './ios/plugins/'
const platforms = [androidDir, iosDir]
const pluginManifests = {
buysell: [],
spend: []
}
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.buysell) {
plugins.buysell.forEach(function (plugin) {
const manifest = copyAssets(plugin)
pluginManifests.buysell.push(manifest)
})
}
if (plugins.spend) {
plugins.spend.forEach(function (plugin) {
const manifest = copyAssets(plugin)
pluginManifests.spend.push(manifest)
})
}
fs.writeFileSync(pluginsFile, JSON.stringify(pluginManifests, null, 2))