react-native/local-cli/util/findReactNativeScripts.js

29 lines
564 B
JavaScript
Raw Normal View History

Make the CLI recognize CRNA projects Summary: 1. Make running `react-native run-ios` or `react-native run-android` inside a project created with Create React Native App run the corresponding react-native-scripts command instead of failing. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 32" src="https://user-images.githubusercontent.com/497214/28467425-86b309c8-6e38-11e7-8946-139bda927d93.png"><img width="762" alt="screen shot 2017-07-21 at 16 55 52" src="https://user-images.githubusercontent.com/497214/28467436-8df02482-6e38-11e7-8a03-3fa664944cac.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 52 15" src="https://user-images.githubusercontent.com/497214/28467522-e4bb6cae-6e38-11e7-97bb-9cfa9cb4dc67.png"> 2. Make running `react-native link` inside a CRNA project display a helpful error message. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 10" src="https://user-images.githubusercontent.com/497214/28467608-1d1781fa-6e39-11e7-9620-cc16c8b1b40f.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 53 10" src="https://user-images.githubusercontent.com/497214/28467637-2cd6ed1a-6e39-11e7-8947-6df69b3f321e.png"> Fixes #14828. * Run `react-native run-ios`, `react-native run-android` and `react-native link` in: * A CRNA project (screenshot above) * A traditional RN project (existing behaviour) * A folder that contains neither (existing behaviour) Closes https://github.com/facebook/react-native/pull/15139 Differential Revision: D5498914 Pulled By: hramos fbshipit-source-id: 94b6196e3451857bbaa45335a01643c89bed19a0
2017-08-03 18:55:40 +00:00
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Make the CLI recognize CRNA projects Summary: 1. Make running `react-native run-ios` or `react-native run-android` inside a project created with Create React Native App run the corresponding react-native-scripts command instead of failing. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 32" src="https://user-images.githubusercontent.com/497214/28467425-86b309c8-6e38-11e7-8946-139bda927d93.png"><img width="762" alt="screen shot 2017-07-21 at 16 55 52" src="https://user-images.githubusercontent.com/497214/28467436-8df02482-6e38-11e7-8a03-3fa664944cac.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 52 15" src="https://user-images.githubusercontent.com/497214/28467522-e4bb6cae-6e38-11e7-97bb-9cfa9cb4dc67.png"> 2. Make running `react-native link` inside a CRNA project display a helpful error message. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 10" src="https://user-images.githubusercontent.com/497214/28467608-1d1781fa-6e39-11e7-9620-cc16c8b1b40f.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 53 10" src="https://user-images.githubusercontent.com/497214/28467637-2cd6ed1a-6e39-11e7-8947-6df69b3f321e.png"> Fixes #14828. * Run `react-native run-ios`, `react-native run-android` and `react-native link` in: * A CRNA project (screenshot above) * A traditional RN project (existing behaviour) * A folder that contains neither (existing behaviour) Closes https://github.com/facebook/react-native/pull/15139 Differential Revision: D5498914 Pulled By: hramos fbshipit-source-id: 94b6196e3451857bbaa45335a01643c89bed19a0
2017-08-03 18:55:40 +00:00
*
* @format
* @flow strict
Make the CLI recognize CRNA projects Summary: 1. Make running `react-native run-ios` or `react-native run-android` inside a project created with Create React Native App run the corresponding react-native-scripts command instead of failing. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 32" src="https://user-images.githubusercontent.com/497214/28467425-86b309c8-6e38-11e7-8946-139bda927d93.png"><img width="762" alt="screen shot 2017-07-21 at 16 55 52" src="https://user-images.githubusercontent.com/497214/28467436-8df02482-6e38-11e7-8a03-3fa664944cac.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 52 15" src="https://user-images.githubusercontent.com/497214/28467522-e4bb6cae-6e38-11e7-97bb-9cfa9cb4dc67.png"> 2. Make running `react-native link` inside a CRNA project display a helpful error message. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 10" src="https://user-images.githubusercontent.com/497214/28467608-1d1781fa-6e39-11e7-9620-cc16c8b1b40f.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 53 10" src="https://user-images.githubusercontent.com/497214/28467637-2cd6ed1a-6e39-11e7-8947-6df69b3f321e.png"> Fixes #14828. * Run `react-native run-ios`, `react-native run-android` and `react-native link` in: * A CRNA project (screenshot above) * A traditional RN project (existing behaviour) * A folder that contains neither (existing behaviour) Closes https://github.com/facebook/react-native/pull/15139 Differential Revision: D5498914 Pulled By: hramos fbshipit-source-id: 94b6196e3451857bbaa45335a01643c89bed19a0
2017-08-03 18:55:40 +00:00
*/
Make the CLI recognize CRNA projects Summary: 1. Make running `react-native run-ios` or `react-native run-android` inside a project created with Create React Native App run the corresponding react-native-scripts command instead of failing. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 32" src="https://user-images.githubusercontent.com/497214/28467425-86b309c8-6e38-11e7-8946-139bda927d93.png"><img width="762" alt="screen shot 2017-07-21 at 16 55 52" src="https://user-images.githubusercontent.com/497214/28467436-8df02482-6e38-11e7-8a03-3fa664944cac.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 52 15" src="https://user-images.githubusercontent.com/497214/28467522-e4bb6cae-6e38-11e7-97bb-9cfa9cb4dc67.png"> 2. Make running `react-native link` inside a CRNA project display a helpful error message. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 10" src="https://user-images.githubusercontent.com/497214/28467608-1d1781fa-6e39-11e7-9620-cc16c8b1b40f.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 53 10" src="https://user-images.githubusercontent.com/497214/28467637-2cd6ed1a-6e39-11e7-8947-6df69b3f321e.png"> Fixes #14828. * Run `react-native run-ios`, `react-native run-android` and `react-native link` in: * A CRNA project (screenshot above) * A traditional RN project (existing behaviour) * A folder that contains neither (existing behaviour) Closes https://github.com/facebook/react-native/pull/15139 Differential Revision: D5498914 Pulled By: hramos fbshipit-source-id: 94b6196e3451857bbaa45335a01643c89bed19a0
2017-08-03 18:55:40 +00:00
'use strict';
const path = require('path');
const fs = require('fs');
function findReactNativeScripts(): ?string {
const executablePath = path.resolve(
'node_modules',
'.bin',
'react-native-scripts',
Make the CLI recognize CRNA projects Summary: 1. Make running `react-native run-ios` or `react-native run-android` inside a project created with Create React Native App run the corresponding react-native-scripts command instead of failing. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 32" src="https://user-images.githubusercontent.com/497214/28467425-86b309c8-6e38-11e7-8946-139bda927d93.png"><img width="762" alt="screen shot 2017-07-21 at 16 55 52" src="https://user-images.githubusercontent.com/497214/28467436-8df02482-6e38-11e7-8a03-3fa664944cac.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 52 15" src="https://user-images.githubusercontent.com/497214/28467522-e4bb6cae-6e38-11e7-97bb-9cfa9cb4dc67.png"> 2. Make running `react-native link` inside a CRNA project display a helpful error message. **Before**: <img width="762" alt="screen shot 2017-07-21 at 16 55 10" src="https://user-images.githubusercontent.com/497214/28467608-1d1781fa-6e39-11e7-9620-cc16c8b1b40f.png"> **After**: <img width="762" alt="screen shot 2017-07-21 at 16 53 10" src="https://user-images.githubusercontent.com/497214/28467637-2cd6ed1a-6e39-11e7-8947-6df69b3f321e.png"> Fixes #14828. * Run `react-native run-ios`, `react-native run-android` and `react-native link` in: * A CRNA project (screenshot above) * A traditional RN project (existing behaviour) * A folder that contains neither (existing behaviour) Closes https://github.com/facebook/react-native/pull/15139 Differential Revision: D5498914 Pulled By: hramos fbshipit-source-id: 94b6196e3451857bbaa45335a01643c89bed19a0
2017-08-03 18:55:40 +00:00
);
if (fs.existsSync(executablePath)) {
return executablePath;
}
return null;
}
module.exports = findReactNativeScripts;