-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostinstall.js
More file actions
35 lines (31 loc) · 909 Bytes
/
postinstall.js
File metadata and controls
35 lines (31 loc) · 909 Bytes
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
const chalk = require("chalk");
const { readFile, writeFile, copyFile } = require("fs").promises;
console.log(chalk.green("here"));
function log(...args) {
console.log(chalk.yellow("[react-native-maps]"), ...args);
}
reactNativeMaps = async function () {
log(
"📦 Creating web compatibility of react-native-maps using an empty module loaded on web builds"
);
const modulePath = "node_modules/react-native-maps";
await writeFile(
`${modulePath}/lib/index.web.js`,
"module.exports = {}",
"utf-8"
);
await copyFile(
`${modulePath}/lib/index.d.ts`,
`${modulePath}/lib/index.web.d.ts`
);
const pkg = JSON.parse(await readFile(`${modulePath}/package.json`));
pkg["react-native"] = "lib/index.js";
pkg["main"] = "lib/index.web.js";
await writeFile(
`${modulePath}/package.json`,
JSON.stringify(pkg, null, 2),
"utf-8"
);
log("✅ script ran successfully");
};
reactNativeMaps();