Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 6a987ed

Browse files
authored
Merge pull request #404 from Microsoft/generate-hash-no-assets
Android binary hashing when there are no asset files
2 parents c51865b + 6532c4a commit 6a987ed

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

scripts/generateBundledResourcesHash.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,29 @@ if (bundleGeneratedAssetFiles.length) {
5151
// Generate hash for each asset file
5252
addFileToManifest(resourcesDir, assetFile, manifest, function() {
5353
if (manifest.length === bundleGeneratedAssetFiles.length) {
54-
// Generate hash for JS bundle
55-
addFileToManifest(path.dirname(jsBundleFilePath), path.basename(jsBundleFilePath), manifest, function() {
56-
// ...and the JS bundle "meta"
57-
var jsBundleMetaFilePath = jsBundleFilePath + ".meta";
58-
addFileToManifest(path.dirname(jsBundleMetaFilePath), path.basename(jsBundleMetaFilePath), manifest, function() {
59-
manifest = manifest.sort();
60-
var finalHash = crypto.createHash(HASH_ALGORITHM)
61-
.update(JSON.stringify(manifest))
62-
.digest("hex");
63-
64-
var savedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_FILE_NAME;
65-
fs.writeFileSync(savedResourcesManifestPath, finalHash);
66-
});
67-
});
54+
addJsBundleAndMetaToManifest();
6855
}
6956
});
7057
});
58+
} else {
59+
addJsBundleAndMetaToManifest();
60+
}
61+
62+
function addJsBundleAndMetaToManifest() {
63+
addFileToManifest(path.dirname(jsBundleFilePath), path.basename(jsBundleFilePath), manifest, function() {
64+
var jsBundleMetaFilePath = jsBundleFilePath + ".meta";
65+
addFileToManifest(path.dirname(jsBundleMetaFilePath), path.basename(jsBundleMetaFilePath), manifest, function() {
66+
manifest = manifest.sort();
67+
var finalHash = crypto.createHash(HASH_ALGORITHM)
68+
.update(JSON.stringify(manifest))
69+
.digest("hex");
70+
71+
console.log(finalHash);
72+
73+
var savedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_FILE_NAME;
74+
fs.writeFileSync(savedResourcesManifestPath, finalHash);
75+
});
76+
});
7177
}
7278

7379
function addFileToManifest(folder, assetFile, manifest, done) {
@@ -98,4 +104,4 @@ function fileExists(file) {
98104
catch (e) { return false; }
99105
}
100106

101-
fs.unlinkSync(TEMP_FILE_PATH);
107+
fs.unlinkSync(TEMP_FILE_PATH);

0 commit comments

Comments
 (0)