From 802578a78e3a68636d698de0eef46560c4a3e2e2 Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Tue, 8 Sep 2015 11:45:03 -0700 Subject: [PATCH] [ReactNative] Pipe `platform` option all the way to the asset server --- react-packager/src/AssetServer/index.js | 4 ++-- react-packager/src/Bundler/index.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/react-packager/src/AssetServer/index.js b/react-packager/src/AssetServer/index.js index 5e4c1127..5783e991 100644 --- a/react-packager/src/AssetServer/index.js +++ b/react-packager/src/AssetServer/index.js @@ -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( diff --git a/react-packager/src/Bundler/index.js b/react-packager/src/Bundler/index.js index 8f76ce10..5f2ead1c 100644 --- a/react-packager/src/Bundler/index.js +++ b/react-packager/src/Bundler/index.js @@ -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(); } @@ -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 { @@ -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];