@evilmartians/lefthook-installer 1.10.4 → 1.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/schema.json +567 -0
- package/install.js +0 -86
package/package.json
CHANGED
package/schema.json
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://json.schemastore.org/lefthook.json",
|
|
4
|
+
"$defs": {
|
|
5
|
+
"Command": {
|
|
6
|
+
"properties": {
|
|
7
|
+
"run": {
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
"files": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"skip": {
|
|
14
|
+
"oneOf": [
|
|
15
|
+
{
|
|
16
|
+
"type": "boolean"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "array"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"only": {
|
|
24
|
+
"oneOf": [
|
|
25
|
+
{
|
|
26
|
+
"type": "boolean"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "array"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"tags": {
|
|
34
|
+
"oneOf": [
|
|
35
|
+
{
|
|
36
|
+
"type": "string"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "array"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"items": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"env": {
|
|
47
|
+
"additionalProperties": {
|
|
48
|
+
"type": "string"
|
|
49
|
+
},
|
|
50
|
+
"type": "object"
|
|
51
|
+
},
|
|
52
|
+
"file_types": {
|
|
53
|
+
"items": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"type": "array"
|
|
57
|
+
},
|
|
58
|
+
"glob": {
|
|
59
|
+
"type": "string"
|
|
60
|
+
},
|
|
61
|
+
"root": {
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"exclude": {
|
|
65
|
+
"oneOf": [
|
|
66
|
+
{
|
|
67
|
+
"type": "string"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"type": "array"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"priority": {
|
|
75
|
+
"type": "integer"
|
|
76
|
+
},
|
|
77
|
+
"fail_text": {
|
|
78
|
+
"type": "string"
|
|
79
|
+
},
|
|
80
|
+
"interactive": {
|
|
81
|
+
"type": "boolean"
|
|
82
|
+
},
|
|
83
|
+
"use_stdin": {
|
|
84
|
+
"type": "boolean"
|
|
85
|
+
},
|
|
86
|
+
"stage_fixed": {
|
|
87
|
+
"type": "boolean"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"additionalProperties": false,
|
|
91
|
+
"type": "object",
|
|
92
|
+
"required": [
|
|
93
|
+
"run"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"Group": {
|
|
97
|
+
"properties": {
|
|
98
|
+
"root": {
|
|
99
|
+
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"parallel": {
|
|
102
|
+
"type": "boolean"
|
|
103
|
+
},
|
|
104
|
+
"piped": {
|
|
105
|
+
"type": "boolean"
|
|
106
|
+
},
|
|
107
|
+
"jobs": {
|
|
108
|
+
"items": {
|
|
109
|
+
"$ref": "#/$defs/Job"
|
|
110
|
+
},
|
|
111
|
+
"type": "array"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"additionalProperties": false,
|
|
115
|
+
"type": "object",
|
|
116
|
+
"required": [
|
|
117
|
+
"jobs"
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"Hook": {
|
|
121
|
+
"properties": {
|
|
122
|
+
"parallel": {
|
|
123
|
+
"type": "boolean"
|
|
124
|
+
},
|
|
125
|
+
"piped": {
|
|
126
|
+
"type": "boolean"
|
|
127
|
+
},
|
|
128
|
+
"follow": {
|
|
129
|
+
"type": "boolean"
|
|
130
|
+
},
|
|
131
|
+
"files": {
|
|
132
|
+
"type": "string"
|
|
133
|
+
},
|
|
134
|
+
"exclude_tags": {
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "string"
|
|
137
|
+
},
|
|
138
|
+
"type": "array"
|
|
139
|
+
},
|
|
140
|
+
"skip": {
|
|
141
|
+
"oneOf": [
|
|
142
|
+
{
|
|
143
|
+
"type": "boolean"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "array"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"only": {
|
|
151
|
+
"oneOf": [
|
|
152
|
+
{
|
|
153
|
+
"type": "boolean"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"type": "array"
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
"jobs": {
|
|
161
|
+
"items": {
|
|
162
|
+
"$ref": "#/$defs/Job"
|
|
163
|
+
},
|
|
164
|
+
"type": "array"
|
|
165
|
+
},
|
|
166
|
+
"commands": {
|
|
167
|
+
"additionalProperties": {
|
|
168
|
+
"$ref": "#/$defs/Command"
|
|
169
|
+
},
|
|
170
|
+
"type": "object"
|
|
171
|
+
},
|
|
172
|
+
"scripts": {
|
|
173
|
+
"additionalProperties": {
|
|
174
|
+
"$ref": "#/$defs/Script"
|
|
175
|
+
},
|
|
176
|
+
"type": "object"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"additionalProperties": false,
|
|
180
|
+
"type": "object"
|
|
181
|
+
},
|
|
182
|
+
"Job": {
|
|
183
|
+
"oneOf": [
|
|
184
|
+
{
|
|
185
|
+
"required": [
|
|
186
|
+
"run"
|
|
187
|
+
],
|
|
188
|
+
"title": "Run a command"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"required": [
|
|
192
|
+
"script"
|
|
193
|
+
],
|
|
194
|
+
"title": "Run a script"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"required": [
|
|
198
|
+
"group"
|
|
199
|
+
],
|
|
200
|
+
"title": "Run a group"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"properties": {
|
|
204
|
+
"name": {
|
|
205
|
+
"type": "string"
|
|
206
|
+
},
|
|
207
|
+
"run": {
|
|
208
|
+
"type": "string"
|
|
209
|
+
},
|
|
210
|
+
"script": {
|
|
211
|
+
"type": "string"
|
|
212
|
+
},
|
|
213
|
+
"runner": {
|
|
214
|
+
"type": "string"
|
|
215
|
+
},
|
|
216
|
+
"glob": {
|
|
217
|
+
"type": "string"
|
|
218
|
+
},
|
|
219
|
+
"root": {
|
|
220
|
+
"type": "string"
|
|
221
|
+
},
|
|
222
|
+
"files": {
|
|
223
|
+
"type": "string"
|
|
224
|
+
},
|
|
225
|
+
"fail_text": {
|
|
226
|
+
"type": "string"
|
|
227
|
+
},
|
|
228
|
+
"tags": {
|
|
229
|
+
"items": {
|
|
230
|
+
"type": "string"
|
|
231
|
+
},
|
|
232
|
+
"type": "array"
|
|
233
|
+
},
|
|
234
|
+
"file_types": {
|
|
235
|
+
"items": {
|
|
236
|
+
"type": "string"
|
|
237
|
+
},
|
|
238
|
+
"type": "array"
|
|
239
|
+
},
|
|
240
|
+
"env": {
|
|
241
|
+
"additionalProperties": {
|
|
242
|
+
"type": "string"
|
|
243
|
+
},
|
|
244
|
+
"type": "object"
|
|
245
|
+
},
|
|
246
|
+
"interactive": {
|
|
247
|
+
"type": "boolean"
|
|
248
|
+
},
|
|
249
|
+
"use_stdin": {
|
|
250
|
+
"type": "boolean"
|
|
251
|
+
},
|
|
252
|
+
"stage_fixed": {
|
|
253
|
+
"type": "boolean"
|
|
254
|
+
},
|
|
255
|
+
"exclude": {
|
|
256
|
+
"oneOf": [
|
|
257
|
+
{
|
|
258
|
+
"type": "string"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"type": "array"
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
},
|
|
265
|
+
"skip": {
|
|
266
|
+
"oneOf": [
|
|
267
|
+
{
|
|
268
|
+
"type": "boolean"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"type": "array"
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
},
|
|
275
|
+
"only": {
|
|
276
|
+
"oneOf": [
|
|
277
|
+
{
|
|
278
|
+
"type": "boolean"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"type": "array"
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
"group": {
|
|
286
|
+
"$ref": "#/$defs/Group"
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
"additionalProperties": false,
|
|
290
|
+
"type": "object"
|
|
291
|
+
},
|
|
292
|
+
"Remote": {
|
|
293
|
+
"properties": {
|
|
294
|
+
"git_url": {
|
|
295
|
+
"type": "string",
|
|
296
|
+
"description": "A URL to Git repository. It will be accessed with privileges of the machine lefthook runs on."
|
|
297
|
+
},
|
|
298
|
+
"ref": {
|
|
299
|
+
"type": "string",
|
|
300
|
+
"description": "An optional *branch* or *tag* name"
|
|
301
|
+
},
|
|
302
|
+
"configs": {
|
|
303
|
+
"items": {
|
|
304
|
+
"type": "string"
|
|
305
|
+
},
|
|
306
|
+
"type": "array",
|
|
307
|
+
"description": "An optional array of config paths from remote's root",
|
|
308
|
+
"default": [
|
|
309
|
+
"lefthook.yml"
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
"refetch": {
|
|
313
|
+
"type": "boolean",
|
|
314
|
+
"description": "Set to true if you want to always refetch the remote"
|
|
315
|
+
},
|
|
316
|
+
"refetch_frequency": {
|
|
317
|
+
"type": "string",
|
|
318
|
+
"description": "Provide a frequency for the remotes refetches",
|
|
319
|
+
"examples": [
|
|
320
|
+
"24h"
|
|
321
|
+
]
|
|
322
|
+
},
|
|
323
|
+
"config": {
|
|
324
|
+
"type": "string",
|
|
325
|
+
"description": "Deprecated: use configs"
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
"additionalProperties": false,
|
|
329
|
+
"type": "object"
|
|
330
|
+
},
|
|
331
|
+
"Script": {
|
|
332
|
+
"properties": {
|
|
333
|
+
"runner": {
|
|
334
|
+
"type": "string"
|
|
335
|
+
},
|
|
336
|
+
"skip": {
|
|
337
|
+
"oneOf": [
|
|
338
|
+
{
|
|
339
|
+
"type": "boolean"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"type": "array"
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
"only": {
|
|
347
|
+
"oneOf": [
|
|
348
|
+
{
|
|
349
|
+
"type": "boolean"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"type": "array"
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
},
|
|
356
|
+
"tags": {
|
|
357
|
+
"oneOf": [
|
|
358
|
+
{
|
|
359
|
+
"type": "string"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"type": "array"
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"items": {
|
|
366
|
+
"type": "string"
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
"env": {
|
|
370
|
+
"additionalProperties": {
|
|
371
|
+
"type": "string"
|
|
372
|
+
},
|
|
373
|
+
"type": "object"
|
|
374
|
+
},
|
|
375
|
+
"priority": {
|
|
376
|
+
"type": "integer"
|
|
377
|
+
},
|
|
378
|
+
"fail_text": {
|
|
379
|
+
"type": "string"
|
|
380
|
+
},
|
|
381
|
+
"interactive": {
|
|
382
|
+
"type": "boolean"
|
|
383
|
+
},
|
|
384
|
+
"use_stdin": {
|
|
385
|
+
"type": "boolean"
|
|
386
|
+
},
|
|
387
|
+
"stage_fixed": {
|
|
388
|
+
"type": "boolean"
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
"additionalProperties": false,
|
|
392
|
+
"type": "object"
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
"$comment": "Last updated on 2025.01.14.",
|
|
396
|
+
"properties": {
|
|
397
|
+
"min_version": {
|
|
398
|
+
"type": "string",
|
|
399
|
+
"description": "Specify a minimum version for the lefthook binary"
|
|
400
|
+
},
|
|
401
|
+
"lefthook": {
|
|
402
|
+
"type": "string",
|
|
403
|
+
"description": "Lefthook executable path or command"
|
|
404
|
+
},
|
|
405
|
+
"source_dir": {
|
|
406
|
+
"type": "string",
|
|
407
|
+
"description": "Change a directory for script files. Directory for script files contains folders with git hook names which contain script files.",
|
|
408
|
+
"default": ".lefthook/"
|
|
409
|
+
},
|
|
410
|
+
"source_dir_local": {
|
|
411
|
+
"type": "string",
|
|
412
|
+
"description": "Change a directory for local script files (not stored in VCS)",
|
|
413
|
+
"default": ".lefthook-local/"
|
|
414
|
+
},
|
|
415
|
+
"rc": {
|
|
416
|
+
"type": "string",
|
|
417
|
+
"description": "Provide an rc file - a simple sh script"
|
|
418
|
+
},
|
|
419
|
+
"skip_output": {
|
|
420
|
+
"oneOf": [
|
|
421
|
+
{
|
|
422
|
+
"type": "boolean"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"type": "array"
|
|
426
|
+
}
|
|
427
|
+
]
|
|
428
|
+
},
|
|
429
|
+
"output": {
|
|
430
|
+
"oneOf": [
|
|
431
|
+
{
|
|
432
|
+
"type": "boolean"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"type": "array"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
438
|
+
"description": "Manage verbosity by skipping the printing of output of some steps"
|
|
439
|
+
},
|
|
440
|
+
"extends": {
|
|
441
|
+
"items": {
|
|
442
|
+
"type": "string"
|
|
443
|
+
},
|
|
444
|
+
"type": "array",
|
|
445
|
+
"description": "Specify files to extend config with"
|
|
446
|
+
},
|
|
447
|
+
"no_tty": {
|
|
448
|
+
"type": "boolean",
|
|
449
|
+
"description": "Whether hide spinner and other interactive things"
|
|
450
|
+
},
|
|
451
|
+
"assert_lefthook_installed": {
|
|
452
|
+
"type": "boolean"
|
|
453
|
+
},
|
|
454
|
+
"colors": {
|
|
455
|
+
"oneOf": [
|
|
456
|
+
{
|
|
457
|
+
"type": "boolean"
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"type": "object"
|
|
461
|
+
}
|
|
462
|
+
],
|
|
463
|
+
"description": "Enable disable or set your own colors for lefthook output"
|
|
464
|
+
},
|
|
465
|
+
"skip_lfs": {
|
|
466
|
+
"type": "boolean",
|
|
467
|
+
"description": "Skip running Git LFS hooks (enabled by default)"
|
|
468
|
+
},
|
|
469
|
+
"remotes": {
|
|
470
|
+
"items": {
|
|
471
|
+
"$ref": "#/$defs/Remote"
|
|
472
|
+
},
|
|
473
|
+
"type": "array",
|
|
474
|
+
"description": "Provide multiple remote configs to use lefthook configurations shared across projects. Lefthook will automatically download and merge configurations into main config."
|
|
475
|
+
},
|
|
476
|
+
"remote": {
|
|
477
|
+
"$ref": "#/$defs/Remote",
|
|
478
|
+
"description": "Deprecated: use remotes"
|
|
479
|
+
},
|
|
480
|
+
"pre-commit": {
|
|
481
|
+
"$ref": "#/$defs/Hook"
|
|
482
|
+
},
|
|
483
|
+
"applypatch-msg": {
|
|
484
|
+
"$ref": "#/$defs/Hook"
|
|
485
|
+
},
|
|
486
|
+
"pre-applypatch": {
|
|
487
|
+
"$ref": "#/$defs/Hook"
|
|
488
|
+
},
|
|
489
|
+
"post-applypatch": {
|
|
490
|
+
"$ref": "#/$defs/Hook"
|
|
491
|
+
},
|
|
492
|
+
"pre-merge-commit": {
|
|
493
|
+
"$ref": "#/$defs/Hook"
|
|
494
|
+
},
|
|
495
|
+
"prepare-commit-msg": {
|
|
496
|
+
"$ref": "#/$defs/Hook"
|
|
497
|
+
},
|
|
498
|
+
"commit-msg": {
|
|
499
|
+
"$ref": "#/$defs/Hook"
|
|
500
|
+
},
|
|
501
|
+
"post-commit": {
|
|
502
|
+
"$ref": "#/$defs/Hook"
|
|
503
|
+
},
|
|
504
|
+
"pre-rebase": {
|
|
505
|
+
"$ref": "#/$defs/Hook"
|
|
506
|
+
},
|
|
507
|
+
"post-checkout": {
|
|
508
|
+
"$ref": "#/$defs/Hook"
|
|
509
|
+
},
|
|
510
|
+
"post-merge": {
|
|
511
|
+
"$ref": "#/$defs/Hook"
|
|
512
|
+
},
|
|
513
|
+
"pre-push": {
|
|
514
|
+
"$ref": "#/$defs/Hook"
|
|
515
|
+
},
|
|
516
|
+
"pre-receive": {
|
|
517
|
+
"$ref": "#/$defs/Hook"
|
|
518
|
+
},
|
|
519
|
+
"update": {
|
|
520
|
+
"$ref": "#/$defs/Hook"
|
|
521
|
+
},
|
|
522
|
+
"proc-receive": {
|
|
523
|
+
"$ref": "#/$defs/Hook"
|
|
524
|
+
},
|
|
525
|
+
"post-receive": {
|
|
526
|
+
"$ref": "#/$defs/Hook"
|
|
527
|
+
},
|
|
528
|
+
"post-update": {
|
|
529
|
+
"$ref": "#/$defs/Hook"
|
|
530
|
+
},
|
|
531
|
+
"reference-transaction": {
|
|
532
|
+
"$ref": "#/$defs/Hook"
|
|
533
|
+
},
|
|
534
|
+
"push-to-checkout": {
|
|
535
|
+
"$ref": "#/$defs/Hook"
|
|
536
|
+
},
|
|
537
|
+
"pre-auto-gc": {
|
|
538
|
+
"$ref": "#/$defs/Hook"
|
|
539
|
+
},
|
|
540
|
+
"post-rewrite": {
|
|
541
|
+
"$ref": "#/$defs/Hook"
|
|
542
|
+
},
|
|
543
|
+
"sendemail-validate": {
|
|
544
|
+
"$ref": "#/$defs/Hook"
|
|
545
|
+
},
|
|
546
|
+
"fsmonitor-watchman": {
|
|
547
|
+
"$ref": "#/$defs/Hook"
|
|
548
|
+
},
|
|
549
|
+
"p4-changelist": {
|
|
550
|
+
"$ref": "#/$defs/Hook"
|
|
551
|
+
},
|
|
552
|
+
"p4-prepare-changelist": {
|
|
553
|
+
"$ref": "#/$defs/Hook"
|
|
554
|
+
},
|
|
555
|
+
"p4-post-changelist": {
|
|
556
|
+
"$ref": "#/$defs/Hook"
|
|
557
|
+
},
|
|
558
|
+
"p4-pre-submit": {
|
|
559
|
+
"$ref": "#/$defs/Hook"
|
|
560
|
+
},
|
|
561
|
+
"post-index-change": {
|
|
562
|
+
"$ref": "#/$defs/Hook"
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
"additionalProperties": false,
|
|
566
|
+
"type": "object"
|
|
567
|
+
}
|
package/install.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const http = require('https')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const path = require("path")
|
|
4
|
-
const chp = require("child_process")
|
|
5
|
-
|
|
6
|
-
const iswin = ["win32", "cygwin"].includes(process.platform)
|
|
7
|
-
|
|
8
|
-
async function install() {
|
|
9
|
-
if (process.env.CI) {
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
const downloadURL = getDownloadURL()
|
|
13
|
-
const extension = iswin ? ".exe" : ""
|
|
14
|
-
const fileName = `lefthook${extension}`
|
|
15
|
-
const exePath = path.join(__dirname, "bin", fileName)
|
|
16
|
-
await downloadBinary(downloadURL, exePath)
|
|
17
|
-
console.log('downloaded to', exePath)
|
|
18
|
-
if (!iswin) {
|
|
19
|
-
fs.chmodSync(exePath, "755")
|
|
20
|
-
}
|
|
21
|
-
// run install
|
|
22
|
-
chp.spawnSync(exePath, ['install', '-f'], {
|
|
23
|
-
cwd: process.env.INIT_CWD || process.cwd(),
|
|
24
|
-
stdio: 'inherit',
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getDownloadURL() {
|
|
29
|
-
// Detect OS
|
|
30
|
-
// https://nodejs.org/api/process.html#process_process_platform
|
|
31
|
-
let goOS = process.platform
|
|
32
|
-
let extension = ""
|
|
33
|
-
if (iswin) {
|
|
34
|
-
goOS = "windows"
|
|
35
|
-
extension = ".exe"
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Convert the goOS to the os name in the download URL
|
|
39
|
-
let downloadOS = goOS === "darwin" ? "macOS" : goOS
|
|
40
|
-
downloadOS = `${downloadOS.charAt(0).toUpperCase()}${downloadOS.slice(1)}`
|
|
41
|
-
|
|
42
|
-
// Detect architecture
|
|
43
|
-
// https://nodejs.org/api/process.html#process_process_arch
|
|
44
|
-
let arch = process.arch
|
|
45
|
-
switch (process.arch) {
|
|
46
|
-
case "x64": {
|
|
47
|
-
arch = "x86_64"
|
|
48
|
-
break
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const version = require("./package.json").version
|
|
52
|
-
|
|
53
|
-
return `https://github.com/evilmartians/lefthook/releases/download/v${version}/lefthook_${version}_${downloadOS}_${arch}${extension}`
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function downloadBinary(url, dest) {
|
|
57
|
-
console.log('downloading', url)
|
|
58
|
-
const file = fs.createWriteStream(dest)
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
http.get(url, function(response) {
|
|
61
|
-
if (response.statusCode === 302 && response.headers.location) {
|
|
62
|
-
// If the response is a 302 redirect, follow the new location
|
|
63
|
-
downloadBinary(response.headers.location, dest)
|
|
64
|
-
.then(resolve)
|
|
65
|
-
.catch(reject)
|
|
66
|
-
} else {
|
|
67
|
-
response.pipe(file)
|
|
68
|
-
|
|
69
|
-
file.on('finish', function() {
|
|
70
|
-
file.close(() => {
|
|
71
|
-
resolve(dest)
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
}).on('error', function(err) {
|
|
76
|
-
fs.unlink(file, () => {
|
|
77
|
-
reject(err)
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// start:
|
|
84
|
-
install().catch((e) => {
|
|
85
|
-
throw e
|
|
86
|
-
})
|