Files
react-native/codegen/buck_tests/generate-tests.js
Eli White a3c6e1da10 Open source the Codegen!
Summary:
This is very much a work in progress. Moving it into the open source repo to be able to hook it up to generate some Fabric files.

Will continue to iterate on it in the open.

Reviewed By: hramos, mdvacca

Differential Revision: D13500969

fbshipit-source-id: 79082447dc52b5834f24eb72bc6e07200b324238
2018-12-20 11:58:11 -08:00

40 lines
887 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 RNCodegen = require('../src/generators/RNCodegen.js');
const fixtures = require('../src/generators/__test_fixtures__/fixtures.js');
const mkdirp = require('mkdirp');
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 outputDirectory = args[1];
mkdirp.sync(outputDirectory);
const fixture = fixtures[fixtureName];
if (fixture == null) {
throw new Error(`Can't find fixture with name ${fixtureName}`);
}
RNCodegen.generate({
libraryName: fixtureName,
schema: fixture,
outputDirectory,
});