2017-05-24 17:06:30 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const asyncCopyTo = require('./utils').asyncCopyTo;
|
|
|
|
|
const chalk = require('chalk');
|
|
|
|
|
const resolvePath = require('./utils').resolvePath;
|
|
|
|
|
|
|
|
|
|
const DEFAULT_FB_SOURCE_PATH = '~/fbsource/';
|
2017-08-30 09:38:14 -07:00
|
|
|
const DEFAULT_WWW_PATH = '~/www/';
|
2018-04-18 13:16:50 -07:00
|
|
|
const RELATIVE_RN_OSS_PATH = 'xplat/js/react-native-github/Libraries/Renderer/';
|
2017-08-30 09:38:14 -07:00
|
|
|
const RELATIVE_WWW_PATH = 'html/shared/react/';
|
|
|
|
|
|
2017-11-27 17:57:28 +00:00
|
|
|
async function doSync(buildPath, destPath) {
|
2017-08-30 09:38:14 -07:00
|
|
|
console.log(`${chalk.bgYellow.black(' SYNCING ')} React to ${destPath}`);
|
|
|
|
|
|
2017-11-27 17:57:28 +00:00
|
|
|
await asyncCopyTo(buildPath, destPath);
|
|
|
|
|
console.log(`${chalk.bgGreen.black(' SYNCED ')} React to ${destPath}`);
|
2017-08-30 09:38:14 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-27 17:57:28 +00:00
|
|
|
async function syncReactDom(buildPath, wwwPath) {
|
2017-08-30 09:38:14 -07:00
|
|
|
wwwPath = typeof wwwPath === 'string' ? wwwPath : DEFAULT_WWW_PATH;
|
|
|
|
|
|
|
|
|
|
if (wwwPath.charAt(wwwPath.length - 1) !== '/') {
|
|
|
|
|
wwwPath += '/';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const destPath = resolvePath(wwwPath + RELATIVE_WWW_PATH);
|
2017-11-27 17:57:28 +00:00
|
|
|
await doSync(buildPath, destPath);
|
2017-08-30 09:38:14 -07:00
|
|
|
}
|
2017-05-24 17:06:30 +01:00
|
|
|
|
2017-11-27 17:57:28 +00:00
|
|
|
async function syncReactNativeHelper(
|
|
|
|
|
buildPath,
|
|
|
|
|
fbSourcePath,
|
|
|
|
|
relativeDestPath
|
|
|
|
|
) {
|
2017-11-07 18:09:33 +00:00
|
|
|
fbSourcePath =
|
|
|
|
|
typeof fbSourcePath === 'string' ? fbSourcePath : DEFAULT_FB_SOURCE_PATH;
|
2017-05-24 17:06:30 +01:00
|
|
|
|
|
|
|
|
if (fbSourcePath.charAt(fbSourcePath.length - 1) !== '/') {
|
|
|
|
|
fbSourcePath += '/';
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-20 12:58:53 -07:00
|
|
|
const destPath = resolvePath(fbSourcePath + relativeDestPath);
|
2017-11-27 17:57:28 +00:00
|
|
|
await doSync(buildPath, destPath);
|
2017-05-24 17:06:30 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-18 13:16:50 -07:00
|
|
|
async function syncReactNative(fbSourcePath) {
|
|
|
|
|
await syncReactNativeHelper(
|
|
|
|
|
'build/react-native',
|
|
|
|
|
fbSourcePath,
|
|
|
|
|
RELATIVE_RN_OSS_PATH
|
|
|
|
|
);
|
2017-10-20 12:58:53 -07:00
|
|
|
}
|
2017-10-10 13:44:43 -07:00
|
|
|
|
2017-05-24 17:06:30 +01:00
|
|
|
module.exports = {
|
2017-08-30 09:38:14 -07:00
|
|
|
syncReactDom,
|
|
|
|
|
syncReactNative,
|
2017-05-24 17:06:30 +01:00
|
|
|
};
|