Hed*_*dge 4 macos node.js npm package.json
我必须postinstall在 MacOS上执行这个脚本(修复 react-native-maps 中的一个临时错误):
"scripts": {
"postinstall": "sed -i '' '/Google.*\\.[h|m]/d' node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj/project.pbxproj"
}
Run Code Online (Sandbox Code Playgroud)
在 Linux 或 Windows 上不需要它,所以我如何只在 macOS 上执行它?
在跨操作系统NPM包似乎做你想要使用的package.json,即到底是什么:
"scripts": {
"foo": "cross-os bar",
"bar": {
"darwin": "echo 'i will only run on Mac'",
"win32": "echo 'i will only run on Windows'",
"linux": "echo 'i will only run on Linux'"
}
}
Run Code Online (Sandbox Code Playgroud)
所以在你的情况下是这样的:
"scripts": {
"postinstall": "cross-os bar"
}
"cross-os": {
"bar": {
"darwin": "echo 'i will only run on Mac'",
"win32": "echo 'i will only run on Windows'",
"linux": "echo 'i will only run on Linux'"
}
}
Run Code Online (Sandbox Code Playgroud)
示例仅来自 repo;命名显然会反映您的用例等。