-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-script.js
More file actions
32 lines (27 loc) · 1.13 KB
/
Copy pathpost-script.js
File metadata and controls
32 lines (27 loc) · 1.13 KB
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
/**
* @file This script is auto-generated by create-nitro-module and should not be edited.
*
* @description This script applies a workaround for Android by modifying the '<ModuleName>OnLoad.cpp' file.
* It reads the file content and removes the 'margelo/nitro/' string from it. This enables support for custom package names.
*
* @module create-nitro-module
*/
const path = require('node:path')
const { writeFile, readFile } = require('node:fs/promises')
const androidWorkaround = async () => {
const androidOnLoadFile = path.join(
process.cwd(),
'nitrogen/generated/android',
'NitroReadiumOnLoad.cpp'
)
const viewManagerFile = path.join(
process.cwd(),
'nitrogen/generated/android/kotlin/com/margelo/nitro/nitroreadium/views',
'HybridNitroReadiumManager.kt'
)
const viewManagerStr = await readFile(viewManagerFile, { encoding: 'utf8' })
await writeFile(viewManagerFile, viewManagerStr.replace(/com\.margelo\.nitro\.nitroreadium\.\*/g, 'com.nitroreadium.*'))
const str = await readFile(androidOnLoadFile, { encoding: 'utf8' })
await writeFile(androidOnLoadFile, str.replace(/margelo\/nitro\//g, ''))
}
androidWorkaround()