diff --git a/packages/core/src/plugins/index.ts b/packages/core/src/plugins/index.ts index 7f4779cf9..c9d1dcf91 100644 --- a/packages/core/src/plugins/index.ts +++ b/packages/core/src/plugins/index.ts @@ -832,6 +832,7 @@ export const overrideFileContents = ( } else if (overrideExists) { if (originalExists) { if (fk.includes(override[fk])) { + foundRegEx = true; fileToFix = fileToFix.replace(originalRegEx, `${override[fk]}`); logSuccess( `${chalk().bold.white(dest)} requires override by: ${chalk().bold.white( @@ -875,6 +876,8 @@ export const overrideFileContents = ( appliedOverrides[packageName].version = packageVersion; fsWriteFileSync(dest, fileToFix); _writeAppliedOverrides(appliedOverrides, appliedOverrideFilePath); + } else if (foundRegEx) { + fsWriteFileSync(dest, fileToFix); } } else { logDebug(`overrideFileContents Warning: path does not exist ${dest}`); @@ -1095,7 +1098,11 @@ export const overrideTemplatePlugins = async () => { logDefault('overrideTemplatePlugins'); const c = getContext(); - + const { skipOverridesCheck } = c.program.opts(); + if (skipOverridesCheck) { + logInfo(`Plugin overrides will not be applied because --skipOverridesCheck parameter was passed.`); + return true; + } const rnvPluginsDirs = c.paths.scopedConfigTemplates.pluginTemplatesDirs; const appPluginDirs = c.paths.appConfig.pluginDirs; diff --git a/packages/core/src/tasks/taskOptions.ts b/packages/core/src/tasks/taskOptions.ts index cd6bc414d..09458a2d4 100644 --- a/packages/core/src/tasks/taskOptions.ts +++ b/packages/core/src/tasks/taskOptions.ts @@ -99,6 +99,12 @@ export const RnvTaskOptions = createTaskOptionsMap([ altKey: 'skipDependencyCheck', description: 'Skips auto update of npm dependencies if mismatch found', }, + { + key: 'skip-overrides-check', + altKey: 'skipOverridesCheck', + description: + 'Skips applying plugin overrides. Useful for avoiding unnecessary checks on every run when overrides are already applied.', + }, { key: 'offline', description: 'Run without connecting to the internet whenever possible', @@ -238,6 +244,7 @@ export const RnvTaskCoreOptionPresets = createTaskOptionsPreset({ RnvTaskOptions.noIntro, RnvTaskOptions.offline, RnvTaskOptions.skipDependencyCheck, + RnvTaskOptions.skipOverridesCheck, ], }); diff --git a/packages/template-starter/scripts/postinstall.js b/packages/template-starter/scripts/postinstall.js index 0341d639a..a78d05dcd 100644 --- a/packages/template-starter/scripts/postinstall.js +++ b/packages/template-starter/scripts/postinstall.js @@ -11,6 +11,7 @@ const { logError, RnvFileName, fsExistsSync, + fsMkdirSync, fsReadFileSync, removeDirSync, revertOverrideToOriginal, @@ -40,7 +41,11 @@ const RNV_HOME_DIR = path.join(__dirname, '..'); })(); const resetOverrides = async () => { - const overrideDir = path.join(process.cwd(), '.rnv', 'overrides'); + const rnvFolder = path.join(process.cwd(), '.rnv'); + if (!fsExistsSync(rnvFolder)) { + fsMkdirSync(rnvFolder); + } + const overrideDir = path.join(rnvFolder, 'overrides'); const appliedOverrideFilePath = path.join(overrideDir, RnvFileName.appliedOverride);