Skip to content

Commit

Permalink
[ReactNative] Pipe platform option all the way to the asset server
Browse files Browse the repository at this point in the history
  • Loading branch information
frantic committed Sep 8, 2015
1 parent c0488c7 commit fb7d7d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packager/react-packager/src/AssetServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class AssetServer {
});
}

getAssetData(assetPath) {
getAssetData(assetPath, platform = null) {
const nameData = getAssetDataFromName(assetPath);
const data = {
name: nameData.name,
type: nameData.type,
};

return this._getAssetRecord(assetPath).then(record => {
return this._getAssetRecord(assetPath, platform).then(record => {
data.scales = record.scales;

return Promise.all(
Expand Down
10 changes: 5 additions & 5 deletions packager/react-packager/src/Bundler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Bundler {
bundle.setMainModuleId(result.mainModuleId);
return Promise.all(
result.dependencies.map(
module => this._transformModule(bundle, module).then(transformed => {
module => this._transformModule(bundle, module, platform).then(transformed => {
if (bar) {
bar.tick();
}
Expand Down Expand Up @@ -182,13 +182,13 @@ class Bundler {
return this._resolver.getDependencies(main, { dev: isDev, platform });
}

_transformModule(bundle, module) {
_transformModule(bundle, module, platform = null) {
let transform;

if (module.isAsset_DEPRECATED()) {
transform = this.generateAssetModule_DEPRECATED(bundle, module);
} else if (module.isAsset()) {
transform = this.generateAssetModule(bundle, module);
transform = this.generateAssetModule(bundle, module, platform);
} else if (module.isJSON()) {
transform = generateJSONModule(module);
} else {
Expand Down Expand Up @@ -243,12 +243,12 @@ class Bundler {
});
}

generateAssetModule(bundle, module) {
generateAssetModule(bundle, module, platform = null) {
const relPath = getPathRelativeToRoot(this._projectRoots, module.path);

return Promise.all([
sizeOf(module.path),
this._assetServer.getAssetData(relPath),
this._assetServer.getAssetData(relPath, platform),
]).then(function(res) {
const dimensions = res[0];
const assetData = res[1];
Expand Down

0 comments on commit fb7d7d6

Please sign in to comment.