11/**
2- * @file This script is auto-generated by create-nitro-module and should not be edited.
3- *
4- * @description This script applies a workaround for Android by modifying the '<ModuleName>OnLoad.cpp' file.
5- * It reads the file content and removes the 'margelo/nitro/' string from it. This enables support for custom package names.
6- *
7- * @module create-nitro-module
8- */
2+ * @file This script is auto-generated by create-nitro-module and should not be edited.
3+ *
4+ * @description This script applies a workaround for Android by modifying the '<ModuleName>OnLoad.cpp' file.
5+ * It reads the file content and removes the 'margelo/nitro/' string from it. This enables support for custom package names.
6+ *
7+ * @module create-nitro-module
8+ */
99const path = require ( 'node:path' )
1010const { writeFile, readFile } = require ( 'node:fs/promises' )
1111const { readdir } = require ( 'node:fs/promises' )
1212
13-
1413const updateViewManagerFiles = async ( file ) => {
1514 const viewManagerFile = path . join (
1615 process . cwd ( ) ,
@@ -26,35 +25,33 @@ const updateViewManagerFiles = async (file) => {
2625 'com.sensitiveinfo.*'
2726 )
2827 )
29- }
30-
28+ }
3129
3230const androidWorkaround = async ( ) => {
33- const androidOnLoadFile = path . join (
34- process . cwd ( ) ,
35- 'nitrogen/generated/android' ,
36- 'SensitiveInfoOnLoad.cpp'
37- )
38-
39- const viewManagerDir = await readdir (
40- path . join (
31+ const androidOnLoadFile = path . join (
4132 process . cwd ( ) ,
42- 'nitrogen/generated/android/kotlin/com/margelo/nitro/sensitiveinfo/views'
33+ 'nitrogen/generated/android' ,
34+ 'SensitiveInfoOnLoad.cpp'
35+ )
36+
37+ const viewManagerDir = await readdir (
38+ path . join (
39+ process . cwd ( ) ,
40+ 'nitrogen/generated/android/kotlin/com/margelo/nitro/sensitiveinfo/views'
41+ )
42+ )
43+ const viewManagerFiles = viewManagerDir . filter ( ( file ) =>
44+ file . endsWith ( 'Manager.kt' )
45+ )
46+ const res = await Promise . allSettled (
47+ viewManagerFiles . map ( updateViewManagerFiles )
4348 )
44- )
45- const viewManagerFiles = viewManagerDir . filter ( ( file ) =>
46- file . endsWith ( 'Manager.kt' )
47- )
48- const res = await Promise . allSettled (
49- viewManagerFiles . map ( updateViewManagerFiles )
50- )
5149
52- if ( res . some ( ( r ) => r . status === 'rejected' ) ) {
53- throw new Error ( `Error updating view manager files: ${ res } ` )
54- }
50+ if ( res . some ( ( r ) => r . status === 'rejected' ) ) {
51+ throw new Error ( `Error updating view manager files: ${ res } ` )
52+ }
5553
56-
57- const str = await readFile ( androidOnLoadFile , { encoding : 'utf8' } )
58- await writeFile ( androidOnLoadFile , str . replace ( / m a r g e l o \/ n i t r o \/ / g, '' ) )
54+ const str = await readFile ( androidOnLoadFile , { encoding : 'utf8' } )
55+ await writeFile ( androidOnLoadFile , str . replace ( / m a r g e l o \/ n i t r o \/ / g, '' ) )
5956}
60- androidWorkaround ( )
57+ androidWorkaround ( )
0 commit comments