mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-14 04:28:43 +08:00
Summary: Change the codegen `srcs` to match any `**/*Schema.js` Reviewed By: TheSavior Differential Revision: D14401232 fbshipit-source-id: 61e60b1c9ca2f33efacc5caa1903b02a93cc644e
37 lines
808 B
JavaScript
37 lines
808 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
import type {SchemaType} from '../src/CodegenSchema.js';
|
|
|
|
function parse(filename: string): ?SchemaType {
|
|
try {
|
|
// $FlowFixMe Can't require dynamic variables
|
|
return require(filename);
|
|
} catch (err) {
|
|
// ignore
|
|
}
|
|
}
|
|
|
|
function combineSchemas(files: Array<string>): SchemaType {
|
|
return files.reduce(
|
|
(merged, filename) => {
|
|
const schema = parse(filename);
|
|
if (schema && schema.modules) {
|
|
merged.modules = {...merged.modules, ...schema.modules};
|
|
}
|
|
return merged;
|
|
},
|
|
{modules: {}},
|
|
);
|
|
}
|
|
|
|
module.exports = combineSchemas;
|