@@ -10,12 +10,12 @@ import {spawnCommand} from "./spawnCommand.js";
10
10
const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
11
11
12
12
export async function compileLlamaCpp ( {
13
- arch = process . arch , nodeTarget = process . version , setUsedBingFlag = true , metal = false , cuda = false
13
+ arch = process . arch , nodeTarget = process . version , setUsedBinFlag : setUsedBinFlagArg = true , metal = false , cuda = false
14
14
} : {
15
- arch ?: string , nodeTarget ?: string , setUsedBingFlag ?: boolean , metal ?: boolean , cuda ?: boolean
15
+ arch ?: string , nodeTarget ?: string , setUsedBinFlag ?: boolean , metal ?: boolean , cuda ?: boolean
16
16
} ) {
17
17
try {
18
- if ( ! ( await fs . exists ( llamaCppDirectory ) ) ) {
18
+ if ( ! ( await fs . pathExists ( llamaCppDirectory ) ) ) {
19
19
throw new Error ( `"${ llamaCppDirectory } " directory does not exist` ) ;
20
20
}
21
21
@@ -46,12 +46,12 @@ export async function compileLlamaCpp({
46
46
47
47
await spawnCommand ( "npm" , [ "run" , "-s" , "node-gyp-llama" , "--" , "configure" , "--arch=" + arch , "--target=" + nodeTarget , "--" , "-f" , "compile_commands_json" ] , __dirname , nodeGypEnv ) ;
48
48
49
- if ( await fs . exists ( path . join ( llamaDirectory , "Release" , "compile_commands.json" ) ) ) {
49
+ if ( await fs . pathExists ( path . join ( llamaDirectory , "Release" , "compile_commands.json" ) ) ) {
50
50
await fs . move (
51
51
path . join ( llamaDirectory , "Release" , "compile_commands.json" ) ,
52
52
path . join ( llamaDirectory , "compile_commands.json" )
53
53
) ;
54
- } else if ( await fs . exists ( path . join ( llamaDirectory , "Debug" , "compile_commands.json" ) ) ) {
54
+ } else if ( await fs . pathExists ( path . join ( llamaDirectory , "Debug" , "compile_commands.json" ) ) ) {
55
55
await fs . move (
56
56
path . join ( llamaDirectory , "Debug" , "compile_commands.json" ) ,
57
57
path . join ( llamaDirectory , "compile_commands.json" )
@@ -64,11 +64,11 @@ export async function compileLlamaCpp({
64
64
65
65
await spawnCommand ( "npm" , [ "run" , "-s" , "node-gyp-llama-build" , "--" , "--arch=" + arch , "--target=" + nodeTarget ] , __dirname , nodeGypEnv ) ;
66
66
67
- if ( setUsedBingFlag ) {
67
+ if ( setUsedBinFlagArg ) {
68
68
await setUsedBinFlag ( "localBuildFromSource" ) ;
69
69
}
70
70
} catch ( err ) {
71
- if ( setUsedBingFlag )
71
+ if ( setUsedBinFlagArg )
72
72
await setUsedBinFlag ( "prebuiltBinaries" ) ;
73
73
74
74
throw err ;
@@ -78,7 +78,7 @@ export async function compileLlamaCpp({
78
78
export async function getCompiledLlamaCppBinaryPath ( ) {
79
79
const modulePath = path . join ( __dirname , ".." , ".." , "llama" , "build" , "Release" , "llama.node" ) ;
80
80
81
- if ( await fs . exists ( modulePath ) )
81
+ if ( await fs . pathExists ( modulePath ) )
82
82
return modulePath ;
83
83
84
84
return null ;
0 commit comments