-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathindex.js
More file actions
675 lines (664 loc) · 28.4 KB
/
index.js
File metadata and controls
675 lines (664 loc) · 28.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
// prettier-ignore
/* eslint-disable */
// @ts-nocheck
/* auto-generated by NAPI-RS */
const { readFileSync } = require('node:fs')
let nativeBinding = null
const loadErrors = []
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
let report = null
if (typeof process.report?.getReport === 'function') {
process.report.excludeNetwork = true
report = process.report.getReport()
}
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try {
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./es-git.android-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-android-arm64')
const bindingPackageVersion = require('es-git-android-arm64/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./es-git.android-arm-eabi.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-android-arm-eabi')
const bindingPackageVersion = require('es-git-android-arm-eabi/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
}
} else if (process.platform === 'win32') {
if (process.arch === 'x64') {
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
try {
return require('./es-git.win32-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-win32-x64-gnu')
const bindingPackageVersion = require('es-git-win32-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./es-git.win32-x64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-win32-x64-msvc')
const bindingPackageVersion = require('es-git-win32-x64-msvc/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ia32') {
try {
return require('./es-git.win32-ia32-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-win32-ia32-msvc')
const bindingPackageVersion = require('es-git-win32-ia32-msvc/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./es-git.win32-arm64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-win32-arm64-msvc')
const bindingPackageVersion = require('es-git-win32-arm64-msvc/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
}
} else if (process.platform === 'darwin') {
try {
return require('./es-git.darwin-universal.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-darwin-universal')
const bindingPackageVersion = require('es-git-darwin-universal/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
if (process.arch === 'x64') {
try {
return require('./es-git.darwin-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-darwin-x64')
const bindingPackageVersion = require('es-git-darwin-x64/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./es-git.darwin-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-darwin-arm64')
const bindingPackageVersion = require('es-git-darwin-arm64/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
}
} else if (process.platform === 'freebsd') {
if (process.arch === 'x64') {
try {
return require('./es-git.freebsd-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-freebsd-x64')
const bindingPackageVersion = require('es-git-freebsd-x64/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./es-git.freebsd-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-freebsd-arm64')
const bindingPackageVersion = require('es-git-freebsd-arm64/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
}
} else if (process.platform === 'linux') {
if (process.arch === 'x64') {
if (isMusl()) {
try {
return require('./es-git.linux-x64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-x64-musl')
const bindingPackageVersion = require('es-git-linux-x64-musl/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./es-git.linux-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-x64-gnu')
const bindingPackageVersion = require('es-git-linux-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm64') {
if (isMusl()) {
try {
return require('./es-git.linux-arm64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-arm64-musl')
const bindingPackageVersion = require('es-git-linux-arm64-musl/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./es-git.linux-arm64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-arm64-gnu')
const bindingPackageVersion = require('es-git-linux-arm64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm') {
if (isMusl()) {
try {
return require('./es-git.linux-arm-musleabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-arm-musleabihf')
const bindingPackageVersion = require('es-git-linux-arm-musleabihf/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./es-git.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-arm-gnueabihf')
const bindingPackageVersion = require('es-git-linux-arm-gnueabihf/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'loong64') {
if (isMusl()) {
try {
return require('./es-git.linux-loong64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-loong64-musl')
const bindingPackageVersion = require('es-git-linux-loong64-musl/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./es-git.linux-loong64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-loong64-gnu')
const bindingPackageVersion = require('es-git-linux-loong64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {
return require('./es-git.linux-riscv64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-riscv64-musl')
const bindingPackageVersion = require('es-git-linux-riscv64-musl/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./es-git.linux-riscv64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-riscv64-gnu')
const bindingPackageVersion = require('es-git-linux-riscv64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ppc64') {
try {
return require('./es-git.linux-ppc64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-ppc64-gnu')
const bindingPackageVersion = require('es-git-linux-ppc64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 's390x') {
try {
return require('./es-git.linux-s390x-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-linux-s390x-gnu')
const bindingPackageVersion = require('es-git-linux-s390x-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
}
} else if (process.platform === 'openharmony') {
if (process.arch === 'arm64') {
try {
return require('./es-git.openharmony-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-openharmony-arm64')
const bindingPackageVersion = require('es-git-openharmony-arm64/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'x64') {
try {
return require('./es-git.openharmony-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-openharmony-x64')
const bindingPackageVersion = require('es-git-openharmony-x64/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./es-git.openharmony-arm.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('es-git-openharmony-arm')
const bindingPackageVersion = require('es-git-openharmony-arm/package.json').version
if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
}
} else {
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
}
}
nativeBinding = requireNative()
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
let wasiBinding = null
let wasiBindingError = null
try {
wasiBinding = require('./es-git.wasi.cjs')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
wasiBindingError = err
}
}
if (!nativeBinding) {
try {
wasiBinding = require('es-git-wasm32-wasi')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
wasiBindingError.cause = err
loadErrors.push(err)
}
}
}
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
error.cause = wasiBindingError
throw error
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
throw new Error(
`Cannot find native binding. ` +
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
{
cause: loadErrors.reduce((err, cur) => {
cur.cause = err
return cur
}),
},
)
}
throw new Error(`Failed to load native binding`)
}
module.exports = nativeBinding
module.exports.AnnotatedCommit = nativeBinding.AnnotatedCommit
module.exports.Blame = nativeBinding.Blame
module.exports.BlameHunks = nativeBinding.BlameHunks
module.exports.BlameHunksByLine = nativeBinding.BlameHunksByLine
module.exports.Blob = nativeBinding.Blob
module.exports.Branch = nativeBinding.Branch
module.exports.Branches = nativeBinding.Branches
module.exports.Commit = nativeBinding.Commit
module.exports.Config = nativeBinding.Config
module.exports.ConfigEntries = nativeBinding.ConfigEntries
module.exports.Deltas = nativeBinding.Deltas
module.exports.Describe = nativeBinding.Describe
module.exports.Diff = nativeBinding.Diff
module.exports.DiffDelta = nativeBinding.DiffDelta
module.exports.DiffFile = nativeBinding.DiffFile
module.exports.DiffStats = nativeBinding.DiffStats
module.exports.GitObject = nativeBinding.GitObject
module.exports.Index = nativeBinding.Index
module.exports.IndexEntries = nativeBinding.IndexEntries
module.exports.Mailmap = nativeBinding.Mailmap
module.exports.Note = nativeBinding.Note
module.exports.Notes = nativeBinding.Notes
module.exports.Rebase = nativeBinding.Rebase
module.exports.Reference = nativeBinding.Reference
module.exports.Reflog = nativeBinding.Reflog
module.exports.ReflogEntry = nativeBinding.ReflogEntry
module.exports.ReflogIter = nativeBinding.ReflogIter
module.exports.Remote = nativeBinding.Remote
module.exports.Repository = nativeBinding.Repository
module.exports.Revwalk = nativeBinding.Revwalk
module.exports.StashEntry = nativeBinding.StashEntry
module.exports.StashList = nativeBinding.StashList
module.exports.StashListIter = nativeBinding.StashListIter
module.exports.StatusEntry = nativeBinding.StatusEntry
module.exports.Statuses = nativeBinding.Statuses
module.exports.StatusesIter = nativeBinding.StatusesIter
module.exports.Submodule = nativeBinding.Submodule
module.exports.Tag = nativeBinding.Tag
module.exports.Tree = nativeBinding.Tree
module.exports.TreeEntry = nativeBinding.TreeEntry
module.exports.TreeIter = nativeBinding.TreeIter
module.exports.Worktree = nativeBinding.Worktree
module.exports.ApplyLocation = nativeBinding.ApplyLocation
module.exports.AutotagOption = nativeBinding.AutotagOption
module.exports.BranchType = nativeBinding.BranchType
module.exports.cloneRepository = nativeBinding.cloneRepository
module.exports.ConfigLevel = nativeBinding.ConfigLevel
module.exports.createMailmapFromBuffer = nativeBinding.createMailmapFromBuffer
module.exports.createSignature = nativeBinding.createSignature
module.exports.CredentialType = nativeBinding.CredentialType
module.exports.DeltaType = nativeBinding.DeltaType
module.exports.DiffFlags = nativeBinding.DiffFlags
module.exports.diffFlagsContains = nativeBinding.diffFlagsContains
module.exports.DiffFormat = nativeBinding.DiffFormat
module.exports.Direction = nativeBinding.Direction
module.exports.discoverRepository = nativeBinding.discoverRepository
module.exports.FetchPrune = nativeBinding.FetchPrune
module.exports.FileFavor = nativeBinding.FileFavor
module.exports.FileMode = nativeBinding.FileMode
module.exports.findGlobalConfigPath = nativeBinding.findGlobalConfigPath
module.exports.findSystemConfigPath = nativeBinding.findSystemConfigPath
module.exports.findXdgConfigPath = nativeBinding.findXdgConfigPath
module.exports.hashFileOid = nativeBinding.hashFileOid
module.exports.hashObjectOid = nativeBinding.hashObjectOid
module.exports.IndexStage = nativeBinding.IndexStage
module.exports.initRepository = nativeBinding.initRepository
module.exports.isValidBranchName = nativeBinding.isValidBranchName
module.exports.isValidOid = nativeBinding.isValidOid
module.exports.isValidReferenceName = nativeBinding.isValidReferenceName
module.exports.isValidTagName = nativeBinding.isValidTagName
module.exports.isZeroOid = nativeBinding.isZeroOid
module.exports.normalizeReferenceName = nativeBinding.normalizeReferenceName
module.exports.ObjectType = nativeBinding.ObjectType
module.exports.openConfig = nativeBinding.openConfig
module.exports.openDefaultConfig = nativeBinding.openDefaultConfig
module.exports.openRepository = nativeBinding.openRepository
module.exports.openRepositoryFromWorktree = nativeBinding.openRepositoryFromWorktree
module.exports.openWorktreeFromRepository = nativeBinding.openWorktreeFromRepository
module.exports.parseConfigBool = nativeBinding.parseConfigBool
module.exports.parseConfigI32 = nativeBinding.parseConfigI32
module.exports.parseConfigI64 = nativeBinding.parseConfigI64
module.exports.RebaseOperationType = nativeBinding.RebaseOperationType
module.exports.ReferenceFormat = nativeBinding.ReferenceFormat
module.exports.ReferenceType = nativeBinding.ReferenceType
module.exports.RemoteRedirect = nativeBinding.RemoteRedirect
module.exports.RepositoryInitMode = nativeBinding.RepositoryInitMode
module.exports.RepositoryState = nativeBinding.RepositoryState
module.exports.RevparseMode = nativeBinding.RevparseMode
module.exports.revparseModeContains = nativeBinding.revparseModeContains
module.exports.RevwalkSort = nativeBinding.RevwalkSort
module.exports.StatusShow = nativeBinding.StatusShow
module.exports.SubmoduleIgnore = nativeBinding.SubmoduleIgnore
module.exports.SubmoduleStatus = nativeBinding.SubmoduleStatus
module.exports.submoduleStatusContains = nativeBinding.submoduleStatusContains
module.exports.SubmoduleUpdate = nativeBinding.SubmoduleUpdate
module.exports.traceClear = nativeBinding.traceClear
module.exports.TraceLevel = nativeBinding.TraceLevel
module.exports.traceSet = nativeBinding.traceSet
module.exports.TreeWalkMode = nativeBinding.TreeWalkMode
module.exports.WorktreeLockStatusType = nativeBinding.WorktreeLockStatusType
module.exports.zeroOid = nativeBinding.zeroOid