diff --git a/android/codepush.gradle b/android/codepush.gradle index b3d5ab8..76e5a36 100644 --- a/android/codepush.gradle +++ b/android/codepush.gradle @@ -52,11 +52,13 @@ gradle.projectsEvaluated { def jsBundleFile = file("$jsBundleDir/$bundleAssetName") + def resourcesMapTempFileName = "CodePushResourcesMap-" + java.util.UUID.randomUUID().toString().substring(0,8) + ".json" + // Make this task run right before the bundle task def recordFilesBeforeBundleCommand = tasks.create( name: "recordFilesBeforeBundleCommand${targetName}", type: Exec) { - commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js", resourcesDir + commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js", resourcesDir, resourcesMapTempFileName } recordFilesBeforeBundleCommand.dependsOn("merge${targetName}Resources") @@ -67,7 +69,7 @@ gradle.projectsEvaluated { def generateBundledResourcesHash = tasks.create( name: "generateBundledResourcesHash${targetName}", type: Exec) { - commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, "$jsBundleDir/$bundleAssetName", jsBundleDir + commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, "$jsBundleDir/$bundleAssetName", jsBundleDir, resourcesMapTempFileName } generateBundledResourcesHash.dependsOn("bundle${targetName}JsAndAssets") diff --git a/scripts/generateBundledResourcesHash.js b/scripts/generateBundledResourcesHash.js index f0cfdfd..876f8a7 100644 --- a/scripts/generateBundledResourcesHash.js +++ b/scripts/generateBundledResourcesHash.js @@ -21,16 +21,18 @@ var CODE_PUSH_FOLDER_PREFIX = "CodePush"; var CODE_PUSH_HASH_FILE_NAME = "CodePushHash"; var CODE_PUSH_HASH_OLD_FILE_NAME = "CodePushHash.json"; var HASH_ALGORITHM = "sha256"; -var TEMP_FILE_PATH = path.join(require("os").tmpdir(), "CodePushResourcesMap.json"); var resourcesDir = process.argv[2]; var jsBundleFilePath = process.argv[3]; var assetsDir = process.argv[4]; +var tempFileName = process.argv[5]; + +var tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName); var resourceFiles = []; getFilesInFolder(resourcesDir, resourceFiles); -var oldFileToModifiedTimeMap = require(TEMP_FILE_PATH); +var oldFileToModifiedTimeMap = require(tempFileLocalPath); var newFileToModifiedTimeMap = {}; resourceFiles.forEach(function(resourceFile) { @@ -114,4 +116,4 @@ function fileExists(file) { catch (e) { return false; } } -fs.unlinkSync(TEMP_FILE_PATH); +fs.unlinkSync(tempFileLocalPath); diff --git a/scripts/recordFilesBeforeBundleCommand.js b/scripts/recordFilesBeforeBundleCommand.js index d2deaf5..60639bd 100644 --- a/scripts/recordFilesBeforeBundleCommand.js +++ b/scripts/recordFilesBeforeBundleCommand.js @@ -11,9 +11,11 @@ var path = require("path"); var getFilesInFolder = require("./getFilesInFolder"); -var TEMP_FILE_PATH = path.join(require("os").tmpdir(), "CodePushResourcesMap.json"); var resourcesDir = process.argv[2]; +var tempFileName = process.argv[3]; + +var tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName); var resourceFiles = []; try { @@ -32,7 +34,7 @@ resourceFiles.forEach(function(resourceFile) { fileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime.getTime(); }); -fs.writeFile(TEMP_FILE_PATH, JSON.stringify(fileToModifiedTimeMap), function(err) { +fs.writeFile(tempFileLocalPath, JSON.stringify(fileToModifiedTimeMap), function(err) { if (err) { throw err; }