Infer platform from extension

Summary: public
Aparently this used to work on 0.11, lets fix it :)

Reviewed By: foghina

Differential Revision: D2557719

fb-gh-sync-id: dcbca077431c1356c89dfc55b71eecff64c7ad3d
This commit is contained in:
Martín Bigio 2015-10-27 17:44:59 -07:00 committed by facebook-github-bot-6
parent 72c55c525b
commit 44af0d3dec
2 changed files with 14 additions and 2 deletions

View File

@ -18,7 +18,6 @@ module.exports = [
command: 'platform',
description: 'Either "ios" or "android"',
type: 'string',
required: true,
}, {
command: 'transformer',
description: 'Specify a custom transformer to be used (absolute path)',

View File

@ -11,6 +11,7 @@
const Activity = require('../Activity');
const AssetServer = require('../AssetServer');
const FileWatcher = require('../FileWatcher');
const getPlatformExtension = require('../lib/getPlatformExtension');
const Bundler = require('../Bundler');
const Promise = require('promise');
@ -173,6 +174,10 @@ class Server {
buildBundle(options) {
return Promise.resolve().then(() => {
if (!options.platform) {
options.platform = getPlatformExtension(options.entryFile);
}
const opts = bundleOpts(options);
return this._bundler.bundle(
opts.entryFile,
@ -191,6 +196,10 @@ class Server {
getDependencies(options) {
return Promise.resolve().then(() => {
if (!options.platform) {
options.platform = getPlatformExtension(options.entryFile);
}
const opts = dependencyOpts(options);
return this._bundler.getDependencies(
opts.entryFile,
@ -432,6 +441,10 @@ class Server {
const sourceMapUrlObj = _.clone(urlObj);
sourceMapUrlObj.pathname = pathname.replace(/\.bundle$/, '.map');
// try to get the platform from the url
const platform = urlObj.query.platform ||
getPlatformExtension(pathname);
return {
sourceMapUrl: url.format(sourceMapUrlObj),
entryFile: entryFile,
@ -443,7 +456,7 @@ class Server {
'inlineSourceMap',
false
),
platform: urlObj.query.platform,
platform: platform,
};
}