Skip to content

Commit

Permalink
change android assets filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
vovanmozg committed Nov 7, 2017
1 parent f983624 commit 67ba7d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 2 additions & 5 deletions local-cli/bundle/assetPathUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'use strict';

import type {PackagerAsset} from '../../Libraries/Image/AssetRegistry';
import md5 from 'md5';

/**
* FIXME: using number to represent discrete scale numbers is fragile in essence because of
Expand Down Expand Up @@ -43,11 +44,7 @@ function getAndroidDrawableFolderName(asset: PackagerAsset, scale: number) {

function getAndroidResourceIdentifier(asset: PackagerAsset) {
var folderPath = getBasePath(asset);
return (folderPath + '/' + asset.name)
.toLowerCase()
.replace(/\//g, '_') // Encode folder structure in file name
.replace(/([^a-z0-9_])/g, '') // Remove illegal chars
.replace(/^assets_/, ''); // Remove "assets_" prefix
return 'a' + md5(folderPath + '/' + asset.name).toLowerCase();
}

function getBasePath(asset: PackagerAsset) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"graceful-fs": "^4.1.3",
"inquirer": "^3.0.6",
"lodash": "^4.16.6",
"md5": "^2.2.1",
"metro-bundler": "^0.20.0",
"mime": "^1.3.4",
"minimist": "^1.2.0",
Expand Down Expand Up @@ -206,4 +207,4 @@
"shelljs": "^0.7.8",
"sinon": "^2.2.0"
}
}
}

0 comments on commit 67ba7d5

Please sign in to comment.