diff --git a/docs/generated/packages/expo/executors/install.json b/docs/generated/packages/expo/executors/install.json index 1c583fa416..bfc9c1982a 100644 --- a/docs/generated/packages/expo/executors/install.json +++ b/docs/generated/packages/expo/executors/install.json @@ -27,6 +27,11 @@ "type": "boolean", "description": "Automatically update any invalid package versions", "default": false + }, + "force": { + "type": "boolean", + "description": "Force the installation of a package, even if it is already installed", + "default": false } }, "presets": [] diff --git a/e2e/expo/src/expo-legacy.test.ts b/e2e/expo/src/expo-legacy.test.ts index a9dada0671..2d970e07b2 100644 --- a/e2e/expo/src/expo-legacy.test.ts +++ b/e2e/expo/src/expo-legacy.test.ts @@ -146,14 +146,14 @@ describe('@nx/expo (legacy)', () => { it('should install', async () => { // run install command let installResults = await runCLIAsync( - `install ${appName} --no-interactive` + `install ${appName} --no-interactive --force` ); expect(installResults.combinedOutput).toContain( 'Successfully ran target install' ); installResults = await runCLIAsync( - `install ${appName} --packages=@react-native-async-storage/async-storage,react-native-image-picker --no-interactive` + `install ${appName} --force --packages=@react-native-async-storage/async-storage,react-native-image-picker --no-interactive` ); expect(installResults.combinedOutput).toContain( 'Successfully ran target install' diff --git a/e2e/expo/src/expo.test.ts b/e2e/expo/src/expo.test.ts index 1946dc3e28..d480ec85cb 100644 --- a/e2e/expo/src/expo.test.ts +++ b/e2e/expo/src/expo.test.ts @@ -117,14 +117,14 @@ describe('@nx/expo', () => { it('should install', async () => { // run install command let installResults = await runCLIAsync( - `install ${appName} --no-interactive` + `install ${appName} --force --no-interactive` ); expect(installResults.combinedOutput).toContain( 'Successfully ran target install' ); installResults = await runCLIAsync( - `install ${appName} --packages=@react-native-async-storage/async-storage,react-native-image-picker --no-interactive` + `install ${appName} --force --packages=@react-native-async-storage/async-storage,react-native-image-picker --no-interactive` ); expect(installResults.combinedOutput).toContain( 'Successfully ran target install' diff --git a/packages/expo/src/executors/install/install.impl.ts b/packages/expo/src/executors/install/install.impl.ts index a8f31a7ee2..52f6b8fb97 100644 --- a/packages/expo/src/executors/install/install.impl.ts +++ b/packages/expo/src/executors/install/install.impl.ts @@ -42,8 +42,14 @@ export async function installAndUpdatePackageJson( ? options.packages.split(',') : options.packages ?? []; - // Use force in case there are any unmet peer dependencies. - await installAsync(packages, createInstallOptions(options), ['--force']); + await installAsync( + packages, + createInstallOptions({ + fix: options.fix, + check: options.check, + }), + createInstallOptions({ force: options.force }) + ); const projectRoot = context.projectsConfigurations.projects[context.projectName].root; diff --git a/packages/expo/src/executors/install/schema.d.ts b/packages/expo/src/executors/install/schema.d.ts index c2161b11ea..2ca7be228e 100644 --- a/packages/expo/src/executors/install/schema.d.ts +++ b/packages/expo/src/executors/install/schema.d.ts @@ -4,4 +4,5 @@ export interface ExpoInstallOptions { packages?: string | string[]; // either a string separated by comma or a string array check?: boolean; // default is false fix?: boolean; // default is false + force?: boolean; // default is false } diff --git a/packages/expo/src/executors/install/schema.json b/packages/expo/src/executors/install/schema.json index ea1869992e..d1acb886b3 100644 --- a/packages/expo/src/executors/install/schema.json +++ b/packages/expo/src/executors/install/schema.json @@ -29,6 +29,11 @@ "type": "boolean", "description": "Automatically update any invalid package versions", "default": false + }, + "force": { + "type": "boolean", + "description": "Force the installation of a package, even if it is already installed", + "default": false } } }