29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
const path = require('path');
|
|
|
|
// Patch _cliConfigAndroid to log
|
|
const Module = require('module');
|
|
const cliPlat = require.resolve('@react-native-community/cli-platform-android');
|
|
const platContent = require('fs').readFileSync(cliPlat, 'utf8');
|
|
// Find _cliConfigAndroid function and patch
|
|
const patched = platContent.replace(
|
|
'function _cliConfigAndroid() {\n const data = require("@react-native-community/cli-config-android");',
|
|
'function _cliConfigAndroid() {\n const data = require("@react-native-community/cli-config-android");\n console.log("CC loaded, keys:", Object.keys(data));',
|
|
);
|
|
// Write to a temp file and require it
|
|
const tmp = './_patched_cli.js';
|
|
require('fs').writeFileSync(tmp, patched);
|
|
delete require.cache[cliPlat];
|
|
const plat = require(tmp);
|
|
console.log('projectConfig type:', typeof plat.projectConfig);
|
|
|
|
// Try loadConfig
|
|
try {
|
|
const cli = require('@react-native-community/cli');
|
|
const cfg = cli.loadConfig({ projectRoot: './' });
|
|
console.log('SUCCESS:', JSON.stringify(cfg.project));
|
|
} catch (e) {
|
|
console.log('FAIL:', e.message);
|
|
}
|
|
|
|
require('fs').unlinkSync(tmp);
|