mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
Use biome instead of eslint/prettier
This commit is contained in:
+46
-52
@@ -1,60 +1,54 @@
|
||||
/**
|
||||
* @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 { readdir } = require('node:fs/promises')
|
||||
|
||||
* @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 { readdir } = require("node:fs/promises");
|
||||
|
||||
const updateViewManagerFiles = async (file) => {
|
||||
const viewManagerFile = path.join(
|
||||
process.cwd(),
|
||||
'nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views',
|
||||
file
|
||||
)
|
||||
|
||||
const viewManagerStr = await readFile(viewManagerFile, { encoding: 'utf8' })
|
||||
await writeFile(
|
||||
viewManagerFile,
|
||||
viewManagerStr.replace(
|
||||
/com\.margelo\.nitro\.omni\.\*/g,
|
||||
'com.omni.*'
|
||||
)
|
||||
)
|
||||
}
|
||||
const viewManagerFile = path.join(
|
||||
process.cwd(),
|
||||
"nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views",
|
||||
file,
|
||||
);
|
||||
|
||||
const viewManagerStr = await readFile(viewManagerFile, { encoding: "utf8" });
|
||||
await writeFile(
|
||||
viewManagerFile,
|
||||
viewManagerStr.replace(/com\.margelo\.nitro\.omni\.\*/g, "com.omni.*"),
|
||||
);
|
||||
};
|
||||
|
||||
const androidWorkaround = async () => {
|
||||
const androidOnLoadFile = path.join(
|
||||
process.cwd(),
|
||||
'nitrogen/generated/android',
|
||||
'OmniOnLoad.cpp'
|
||||
)
|
||||
|
||||
const viewManagerDir = await readdir(
|
||||
path.join(
|
||||
process.cwd(),
|
||||
'nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views'
|
||||
)
|
||||
)
|
||||
const viewManagerFiles = viewManagerDir.filter((file) =>
|
||||
file.endsWith('Manager.kt')
|
||||
)
|
||||
const res = await Promise.allSettled(
|
||||
viewManagerFiles.map(updateViewManagerFiles)
|
||||
)
|
||||
const androidOnLoadFile = path.join(
|
||||
process.cwd(),
|
||||
"nitrogen/generated/android",
|
||||
"OmniOnLoad.cpp",
|
||||
);
|
||||
|
||||
if (res.some((r) => r.status === 'rejected')) {
|
||||
throw new Error(`Error updating view manager files: ${res}`)
|
||||
}
|
||||
const viewManagerDir = await readdir(
|
||||
path.join(
|
||||
process.cwd(),
|
||||
"nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views",
|
||||
),
|
||||
);
|
||||
const viewManagerFiles = viewManagerDir.filter((file) =>
|
||||
file.endsWith("Manager.kt"),
|
||||
);
|
||||
const res = await Promise.allSettled(
|
||||
viewManagerFiles.map(updateViewManagerFiles),
|
||||
);
|
||||
|
||||
|
||||
const str = await readFile(androidOnLoadFile, { encoding: 'utf8' })
|
||||
await writeFile(androidOnLoadFile, str.replace(/margelo\/nitro\//g, ''))
|
||||
}
|
||||
androidWorkaround()
|
||||
if (res.some((r) => r.status === "rejected")) {
|
||||
throw new Error(`Error updating view manager files: ${res}`);
|
||||
}
|
||||
|
||||
const str = await readFile(androidOnLoadFile, { encoding: "utf8" });
|
||||
await writeFile(androidOnLoadFile, str.replace(/margelo\/nitro\//g, ""));
|
||||
};
|
||||
androidWorkaround();
|
||||
|
||||
Reference in New Issue
Block a user