mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-10-08 22:45:16 +08:00
Revert to spawn
This commit is contained in:
@@ -9,7 +9,7 @@ import { ZipFile } from 'yazl';
|
|||||||
import { open as openZipFile } from 'yauzl';
|
import { open as openZipFile } from 'yauzl';
|
||||||
import { question } from './utils';
|
import { question } from './utils';
|
||||||
import { checkPlatform } from './app';
|
import { checkPlatform } from './app';
|
||||||
const { spawn, spawnSync } = require('child_process');
|
const { spawn, spawnSync, execSync } = require('child_process');
|
||||||
const g2js = require('gradle-to-js/lib/parser');
|
const g2js = require('gradle-to-js/lib/parser');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
@@ -56,6 +56,7 @@ async function runReactNativeBundleCommand(
|
|||||||
fs.emptyDirSync(outputFolder);
|
fs.emptyDirSync(outputFolder);
|
||||||
|
|
||||||
Array.prototype.push.apply(reactNativeBundleArgs, [
|
Array.prototype.push.apply(reactNativeBundleArgs, [
|
||||||
|
'bundle',
|
||||||
'--assets-dest',
|
'--assets-dest',
|
||||||
outputFolder,
|
outputFolder,
|
||||||
'--bundle-output',
|
'--bundle-output',
|
||||||
@@ -76,18 +77,29 @@ async function runReactNativeBundleCommand(
|
|||||||
reactNativeBundleArgs.push('--config', config);
|
reactNativeBundleArgs.push('--config', config);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const reactNativeBundleProcess = spawn('react-native', reactNativeBundleArgs);
|
||||||
exec(`
|
console.log(`Running bundle command: react-native ${reactNativeBundleArgs.join(' ')}`);
|
||||||
echo Running "react-native bundle" command:
|
|
||||||
react-native bundle ${reactNativeBundleArgs.join(' ')}
|
return new Promise((resolve, reject) => {
|
||||||
`);
|
reactNativeBundleProcess.stdout.on('data', data => {
|
||||||
if (platform === 'android') {
|
console.log(data.toString().trim());
|
||||||
await compileHermesByteCode(bundleName, outputFolder);
|
});
|
||||||
}
|
|
||||||
} catch (e) {
|
reactNativeBundleProcess.stderr.on('data', data => {
|
||||||
console.log(e);
|
console.error(data.toString().trim());
|
||||||
process.exit(1);
|
});
|
||||||
}
|
|
||||||
|
reactNativeBundleProcess.on('close', async exitCode => {
|
||||||
|
if (exitCode) {
|
||||||
|
reject(new Error(`"react-native bundle" command exited with code ${exitCode}.`));
|
||||||
|
} else {
|
||||||
|
if (platform === 'android') {
|
||||||
|
await compileHermesByteCode(bundleName, outputFolder);
|
||||||
|
}
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHermesOSBin() {
|
function getHermesOSBin() {
|
||||||
@@ -110,11 +122,12 @@ async function compileHermesByteCode(bundleName, outputFolder) {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
if (enableHermes) {
|
if (enableHermes) {
|
||||||
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
||||||
const hermesPath = fs.existsSync('node_modules/hermes-engine') ? 'node_modules/hermes-engine' : 'node_modules/hermesvm';
|
const hermesPath = fs.existsSync('node_modules/hermes-engine')
|
||||||
exec(`
|
? 'node_modules/hermes-engine'
|
||||||
${hermesPath}/${getHermesOSBin()}/hermes -emit-binary -out ${outputFolder}/${bundleName} ${outputFolder}/${bundleName} -O
|
: 'node_modules/hermesvm';
|
||||||
echo Compiling done.
|
execSync(
|
||||||
`);
|
`${hermesPath}/${getHermesOSBin()}/hermes -emit-binary -out ${outputFolder}/${bundleName} ${outputFolder}/${bundleName} -O`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user