diff --git a/package.json b/package.json index b7cc042..9a77819 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update-cli", - "version": "2.3.1", + "version": "2.3.2", "description": "command line tool for react-native-update (remote updates for react native)", "main": "index.js", "bin": { diff --git a/src/bundle.ts b/src/bundle.ts index fda6879..6e5f213 100644 --- a/src/bundle.ts +++ b/src/bundle.ts @@ -85,14 +85,30 @@ async function runReactNativeBundleCommand({ const getExpoCli = () => { try { + const searchPaths = [process.cwd()]; + + // 尝试添加 expo 包的路径作为额外的搜索路径 + try { + const expoPath = require.resolve('expo/package.json', { + paths: [process.cwd()], + }); + // 获取 expo 包的目录路径 + const expoDir = expoPath.replace(/\/package\.json$/, ''); + searchPaths.push(expoDir); + } catch { + // expo 包不存在,忽略 + } + + // 尝试从搜索路径中解析 @expo/cli cliPath = require.resolve('@expo/cli', { - paths: [process.cwd()], + paths: searchPaths, }); + const expoCliVersion = JSON.parse( fs .readFileSync( require.resolve('@expo/cli/package.json', { - paths: [process.cwd()], + paths: searchPaths, }), ) .toString(),