mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 03:50:11 +08:00
Summary: When we actually use the codegen we will be passing in a path to a schema. Refactoring the existing buck rules to take a path to a schema instead of a fixture name so it can be reused. Reviewed By: mdvacca Differential Revision: D13619358 fbshipit-source-id: 1180d2e80c11b93f3cbdb0f9e848ae37bff199f4
34 lines
756 B
JavaScript
34 lines
756 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';
|
|
|
|
const fs = require('fs');
|
|
|
|
const fixtures = require('../src/generators/__test_fixtures__/fixtures.js');
|
|
|
|
const args = process.argv.slice(2);
|
|
if (args.length !== 2) {
|
|
throw new Error(
|
|
'Expected to receive the fixture name and output directory as the only arg',
|
|
);
|
|
}
|
|
|
|
const fixtureName = args[0];
|
|
const outputPath = args[1];
|
|
|
|
const fixture = fixtures[fixtureName];
|
|
|
|
if (fixture == null) {
|
|
throw new Error(`Can't find fixture with name ${fixtureName}`);
|
|
}
|
|
|
|
fs.writeFileSync(outputPath, JSON.stringify(fixture, null, 2));
|