remove support for `process.platform`

Reviewed By: javache

Differential Revision: D3252666

fb-gh-sync-id: af0e4987c34f43ec2472cbdf52fc112b81050513
fbshipit-source-id: af0e4987c34f43ec2472cbdf52fc112b81050513
This commit is contained in:
David Aurelio 2016-05-04 02:50:36 -07:00 committed by Facebook Github Bot 5
parent 4695f84448
commit 5f53658fb0
2 changed files with 0 additions and 21 deletions

View File

@ -165,18 +165,6 @@ describe('inline constants', () => {
normalize(code.replace(/process\.env\.NODE_ENV/, '"development"')));
});
it('replaces process.platform in the code', () => {
const code = `function a() {
if (process.platform === 'android') {
return require('./android');
}
return require('./ios');
}`;
const {ast} = inline('arbitrary.js', {code}, {platform: 'ios'});
expect(toString(ast)).toEqual(
normalize(code.replace(/process\.platform\b/, '"ios"')));
});
it('accepts an AST as input', function() {
const code = 'function ifDev(a,b){return __DEV__?a:b;}';
const {ast} = inline('arbitrary.hs', {ast: toAst(code)}, {dev: false});

View File

@ -20,7 +20,6 @@ const requirePattern = {name: 'require'};
const env = {name: 'env'};
const nodeEnv = {name: 'NODE_ENV'};
const processId = {name: 'process'};
const platformId = {name: 'platform'};
const dev = {name: '__DEV__'};
@ -64,11 +63,6 @@ const isProcessEnvNodeEnv = (node, scope) =>
t.isIdentifier(node.object.object, processId) &&
isGlobal(scope.getBinding(processId.name));
const isProcessPlatform = (node, scope) =>
t.isIdentifier(node.property, platformId) &&
t.isIdentifier(node.object, processId) &&
isGlobal(scope.getBinding(processId.name));
const isDev = (node, parent, scope) =>
t.isIdentifier(node, dev) &&
isGlobal(scope.getBinding(dev.name)) &&
@ -90,9 +84,6 @@ const inlinePlugin = {
} else if (isProcessEnvNodeEnv(node, scope)) {
path.replaceWith(
t.stringLiteral(state.opts.dev ? 'development' : 'production'));
} else if (isProcessPlatform(node, scope)) {
path.replaceWith(
t.stringLiteral(state.opts.platform));
}
},
},