Skip to content

Commit 5793886

Browse files
fix: skip if react-native is not a dependency
1 parent 11c7d27 commit 5793886

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/dependencies.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import appRoot from 'app-root-path';
2+
import path from 'path';
3+
import fs from 'fs';
4+
5+
const packageJsonPath = path.join(appRoot.path, 'package.json');
6+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
7+
8+
const allDependencies = {
9+
...packageJson.dependencies,
10+
...packageJson.devDependencies,
11+
};
12+
13+
export const hasDependency = (name: string) => allDependencies[name] !== undefined;

src/prepare.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { FullPluginConfig, PluginConfig } from './types';
44
import { versionAndroid } from './version/android';
55
import { versionIos } from './version/ios';
66
import { isPreRelease } from './version/utils';
7+
import { hasDependency } from './dependencies';
78

89
const applyPluginConfigDefaults = (pluginConfig: PluginConfig): FullPluginConfig => deepmerge({
910
androidPath: 'android/app/build.gradle',
@@ -30,6 +31,10 @@ export const prepare = async (
3031
const pConfig = applyPluginConfigDefaults(pluginConfig);
3132
const { logger, nextRelease } = context;
3233

34+
if (!hasDependency('react-native')) {
35+
logger.info('Skipping because the project does not have react-native as a dependency');
36+
}
37+
3338
if (isPreRelease(nextRelease) && pluginConfig.noPrerelease) {
3439
logger.info('Skipping pre-release version');
3540

0 commit comments

Comments
 (0)