mirror of
https://github.com/status-im/react-native.git
synced 2025-01-29 10:45:04 +00:00
445182c707
Summary:
Seeing as [Windows is a supported platform](72157cf991/packager/defaults.js (L22)
) until platforms can better manager their own CLI and packager needs.
Linking 3rd party libraries should be supported first, because then I'd like to do a follow up PR with grabbou to identify how we can effectively move RNPM functionality out of react-native core and eventually housed in each external platform's repo. The goal would be working with cpojer and hopefully andrewimm to help keep external platform needs in their respective repos, for rnpm/packager _et al._ Seeing as this is a major discussion point, I've made this PR first. Making small steps towards this goal, seems to be the approved methodology from all.
Additionally, I have a merged PR that makes an excellent place for documenting the CLI when it advances, as preparatio
Closes https://github.com/facebook/react-native/pull/11282
Differential Revision: D4311391
fbshipit-source-id: be9a836344be4aed6c4732b0ce4947c2a16b6dad
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
'use strict';
|
|
|
|
const glob = require('glob');
|
|
const path = require('path');
|
|
|
|
/**
|
|
* Glob pattern to look for solution file
|
|
*/
|
|
const GLOB_PATTERN = '**/*.sln';
|
|
|
|
/**
|
|
* Regexp matching all test projects
|
|
*/
|
|
const TEST_PROJECTS = /test|example|sample/i;
|
|
|
|
/**
|
|
* Base windows folder
|
|
*/
|
|
const WINDOWS_BASE = 'windows';
|
|
|
|
/**
|
|
* These folders will be excluded from search to speed it up
|
|
*/
|
|
const GLOB_EXCLUDE_PATTERN = ['**/@(node_modules)/**'];
|
|
|
|
/**
|
|
* Finds windows project by looking for all .sln files
|
|
* in given folder.
|
|
*
|
|
* Returns first match if files are found or null
|
|
*
|
|
* Note: `./windows/*.sln` are returned regardless of the name
|
|
*/
|
|
module.exports = function findSolution(folder) {
|
|
const projects = glob
|
|
.sync(GLOB_PATTERN, {
|
|
cwd: folder,
|
|
ignore: GLOB_EXCLUDE_PATTERN,
|
|
})
|
|
.filter(project => {
|
|
return path.dirname(project) === WINDOWS_BASE || !TEST_PROJECTS.test(project);
|
|
})
|
|
.sort((projectA, projectB) => {
|
|
return path.dirname(projectA) === WINDOWS_BASE ? -1 : 1;
|
|
});
|
|
|
|
if (projects.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return projects[0];
|
|
};
|