Prettier RN local-cli

Reviewed By: yungsters

Differential Revision: D7962462

fbshipit-source-id: 0afe2092af8703895de91a6d1400315c3173aa6d
This commit is contained in:
Eli White
2018-05-11 12:43:49 -07:00
committed by Facebook Github Bot
parent 680fb50040
commit aba4ec0c09
209 changed files with 3167 additions and 2071 deletions

View File

@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const copyProjectTemplateAndReplace = require('../generator/copyProjectTemplateAndReplace');
@@ -22,13 +25,12 @@ const fs = require('fs');
*/
function eject() {
const doesIOSExist = fs.existsSync(path.resolve('ios'));
const doesAndroidExist = fs.existsSync(path.resolve('android'));
if (doesIOSExist && doesAndroidExist) {
console.error(
'Both the iOS and Android folders already exist! Please delete `ios` and/or `android` ' +
'before ejecting.'
'before ejecting.',
);
process.exit(1);
}
@@ -39,8 +41,10 @@ function eject() {
} catch (e) {
console.error(
'Eject requires an `app.json` config file to be located at ' +
`${path.resolve('app.json')}, and it must at least specify a \`name\` for the project ` +
'name, and a `displayName` for the app\'s home screen label.'
`${path.resolve(
'app.json',
)}, and it must at least specify a \`name\` for the project ` +
"name, and a `displayName` for the app's home screen label.",
);
process.exit(1);
}
@@ -49,7 +53,7 @@ function eject() {
if (!appName) {
console.error(
'App `name` must be defined in the `app.json` config file to define the project name. ' +
'It must not contain any spaces or dashes.'
'It must not contain any spaces or dashes.',
);
process.exit(1);
}
@@ -57,33 +61,46 @@ function eject() {
if (!displayName) {
console.error(
'App `displayName` must be defined in the `app.json` config file, to define the label ' +
'of the app on the home screen.'
'of the app on the home screen.',
);
process.exit(1);
}
const templateOptions = { displayName };
const templateOptions = {displayName};
if (!doesIOSExist) {
console.log('Generating the iOS folder.');
copyProjectTemplateAndReplace(
path.resolve('node_modules', 'react-native', 'local-cli', 'templates', 'HelloWorld', 'ios'),
path.resolve(
'node_modules',
'react-native',
'local-cli',
'templates',
'HelloWorld',
'ios',
),
path.resolve('ios'),
appName,
templateOptions
templateOptions,
);
}
if (!doesAndroidExist) {
console.log('Generating the Android folder.');
copyProjectTemplateAndReplace(
path.resolve('node_modules', 'react-native', 'local-cli', 'templates', 'HelloWorld', 'android'),
path.resolve(
'node_modules',
'react-native',
'local-cli',
'templates',
'HelloWorld',
'android',
),
path.resolve('android'),
appName,
templateOptions
templateOptions,
);
}
}
module.exports = {