@@ -10,12 +10,17 @@ import { logger } from '../util/logger';
1010export interface NodeProp {
1111 version ?: string ;
1212 network ?: Network ;
13+ binaryPath ?: string ;
1314}
1415
15- export function startNode ( { version, network = Network . devnet } : NodeProp ) {
16+ export function startNode ( { version, network = Network . devnet , binaryPath } : NodeProp ) {
17+ if ( binaryPath && network !== Network . devnet ) {
18+ logger . warn ( 'Custom binaryPath is only supported for devnet. The provided binaryPath will be ignored.' ) ;
19+ }
20+
1621 switch ( network ) {
1722 case Network . devnet :
18- return nodeDevnet ( { version } ) ;
23+ return nodeDevnet ( { version, binaryPath } ) ;
1924 case Network . testnet :
2025 return nodeTestnet ( ) ;
2126 case Network . mainnet :
@@ -25,13 +30,19 @@ export function startNode({ version, network = Network.devnet }: NodeProp) {
2530 }
2631}
2732
28- export async function nodeDevnet ( { version } : NodeProp ) {
33+ export async function nodeDevnet ( { version, binaryPath } : NodeProp ) {
2934 const settings = readSettings ( ) ;
3035 const ckbVersion = version || settings . bins . defaultCKBVersion ;
31- await installCKBBinary ( ckbVersion ) ;
32- await initChainIfNeeded ( ) ;
36+ let ckbBinPath = '' ;
3337
34- const ckbBinPath = encodeBinPathForTerminal ( getCKBBinaryPath ( ckbVersion ) ) ;
38+ if ( binaryPath ) {
39+ ckbBinPath = encodeBinPathForTerminal ( binaryPath ) ;
40+ logger . info ( `Using custom CKB binary path: ${ ckbBinPath } ` ) ;
41+ } else {
42+ await installCKBBinary ( ckbVersion ) ;
43+ ckbBinPath = encodeBinPathForTerminal ( getCKBBinaryPath ( ckbVersion ) ) ;
44+ }
45+ await initChainIfNeeded ( ) ;
3546 const devnetConfigPath = encodeBinPathForTerminal ( settings . devnet . configPath ) ;
3647
3748 const ckbCmd = `${ ckbBinPath } run -C ${ devnetConfigPath } ` ;
0 commit comments