forked from DataDog/datadog-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.ts
32 lines (25 loc) · 865 Bytes
/
utils.ts
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
import {existsSync} from 'fs'
import {RNPlatform} from './interfaces'
export const getReactNativeVersion = (packageJsonPath: string): undefined | string => {
if (!existsSync(packageJsonPath)) {
return undefined
}
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires
return require(packageJsonPath).version as string
} catch (e) {
return undefined
}
}
const DEFAULT_ANDROID_BUNDLE_NAME = 'index.android.bundle'
const DEFAULT_IOS_BUNDLE_NAME = 'main.jsbundle'
export const getBundleName = (bundlePath: string | undefined, platform: RNPlatform): string => {
if (bundlePath) {
const splitPath = bundlePath.split('/')
return splitPath[splitPath.length - 1]
}
if (platform === 'ios') {
return DEFAULT_IOS_BUNDLE_NAME
}
return DEFAULT_ANDROID_BUNDLE_NAME
}