From 927b356245dcaaab5e7dbced641ad5884582b089 Mon Sep 17 00:00:00 2001 From: Nicolas Cuillery Date: Sat, 18 Feb 2017 16:41:30 -0800 Subject: [PATCH] Fix react-native-git-upgrade cache busting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: **Motivation** This PR fixes #12420. For the first time, the version 0.41.2 includes a change in the generator (see #12162). The [require cache busting](https://github.com/facebook/react-native/blob/master/react-native-git-upgrade/cliEntry.js#L157-L163) of `react-native-git-upgrade`, designed to face this situation , was ineffective. The entry in `require.cache` is the file path including the `.js` extension. We have to delete this entry with the same key. **Test plan** - Publish `react-native-git-upgrade` to Sinopia, - Follow the reproduction steps of #12420 - 👉 The name of the app shouldn't be changed Closes https://github.com/facebook/react-native/pull/12422 Differential Revision: D4585549 Pulled By: mkonicek fbshipit-source-id: 508ac925c17d02b7739d47f9351a5aa336589f2e --- react-native-git-upgrade/cliEntry.js | 2 +- react-native-git-upgrade/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react-native-git-upgrade/cliEntry.js b/react-native-git-upgrade/cliEntry.js index a42b3a93d9f..8c8d68c51b9 100644 --- a/react-native-git-upgrade/cliEntry.js +++ b/react-native-git-upgrade/cliEntry.js @@ -160,7 +160,7 @@ function runCopyAndReplace(generatorDir, appName) { * This file could have changed between these 2 versions. When generating the new template, * we don't want to load the old version of the generator from the cache */ - delete require.cache[copyProjectTemplateAndReplacePath]; + delete require.cache[require.resolve(copyProjectTemplateAndReplacePath)]; const copyProjectTemplateAndReplace = require(copyProjectTemplateAndReplacePath); copyProjectTemplateAndReplace( path.resolve(generatorDir, '..', 'templates', 'HelloWorld'), diff --git a/react-native-git-upgrade/package.json b/react-native-git-upgrade/package.json index 1b1130207c4..9556cc277a0 100644 --- a/react-native-git-upgrade/package.json +++ b/react-native-git-upgrade/package.json @@ -1,6 +1,6 @@ { "name": "react-native-git-upgrade", - "version": "0.2.6", + "version": "0.2.7", "license": "BSD-3-Clause", "description": "The React Native upgrade tool", "main": "cli.js",