1
1
import * as favicons from 'favicons' ;
2
2
import * as fs from 'fs' ;
3
3
import * as packageJson from '../package.json' ;
4
+ // eslint-disable-next-line unicorn/import-style
4
5
import * as path from 'path' ;
5
6
6
7
const icon = 'react.svg' ;
7
8
8
- const configuration : favicons . Configuration = {
9
- path : `${ packageJson . basename } assets` ,
10
- appName : packageJson . name ,
11
- appShortName : packageJson . name ,
12
- appDescription : packageJson . description ,
13
- developerName : packageJson . author ,
14
- developerURL : packageJson . homepage ,
15
- dir : 'auto' ,
16
- lang : 'en-US' ,
17
- background : '#000' ,
18
- theme_color : '#000' ,
19
- appleStatusBarStyle : 'black-translucent' ,
20
- display : 'standalone' ,
21
- orientation : 'any' ,
22
- scope : '/' ,
23
- start_url : `${ packageJson . basename } index.html` ,
24
- version : '1.0' ,
25
- logging : false ,
26
- pixel_art : false ,
27
- loadManifestWithCredentials : false ,
28
- manifestRelativePaths : false ,
29
- pipeHTML : true ,
30
- icons : {
31
- android : true ,
32
- appleIcon : true ,
33
- appleStartup : true ,
34
- coast : true ,
35
- favicons : true ,
36
- firefox : true ,
37
- windows : true ,
38
- yandex : true ,
39
- } ,
9
+ const configuration : favicons . FaviconOptions = {
10
+ path : `${ packageJson . basename } assets` ,
11
+ appName : packageJson . name ,
12
+ appShortName : packageJson . name ,
13
+ appDescription : packageJson . description ,
14
+ developerName : packageJson . author ,
15
+ developerURL : packageJson . homepage ,
16
+ dir : 'auto' ,
17
+ lang : 'en-US' ,
18
+ background : '#000' ,
19
+ theme_color : '#000' ,
20
+ appleStatusBarStyle : 'black-translucent' ,
21
+ display : 'standalone' ,
22
+ orientation : 'any' ,
23
+ scope : '/' ,
24
+ start_url : `${ packageJson . basename } index.html` ,
25
+ version : '1.0' ,
26
+ logging : false ,
27
+ pixel_art : false ,
28
+ loadManifestWithCredentials : false ,
29
+ manifestRelativePaths : false ,
30
+ pipeHTML : true ,
31
+ icons : {
32
+ android : true ,
33
+ appleIcon : true ,
34
+ appleStartup : true ,
35
+ coast : true ,
36
+ favicons : true ,
37
+ firefox : true ,
38
+ windows : true ,
39
+ yandex : true ,
40
40
} ,
41
- callback = (
42
- error : Error | null ,
43
- response : {
44
- images : { name : string ; contents : Buffer } [ ] ;
45
- files : { name : string ; contents : Buffer } [ ] ;
46
- html : string [ ] ;
47
- } ,
48
- ) => {
49
- if ( error ) {
50
- console . log ( error . message ) ;
51
- return ;
52
- }
41
+ } ;
53
42
43
+ favicons ( icon , configuration )
44
+ . then ( ( response ) => {
54
45
const assetPath = path . resolve ( 'public' , 'assets' ) ;
55
46
56
- const writeFiles = ( files : { name : string ; contents : Buffer } [ ] ) => {
47
+ const writeFiles = (
48
+ files : { name : string ; contents : Buffer | string } [ ] ,
49
+ ) => {
57
50
files . forEach ( ( file ) => {
58
51
fs . writeFileSync ( path . resolve ( assetPath , file . name ) , file . contents ) ;
59
52
} ) ;
@@ -64,7 +57,11 @@ const configuration: favicons.Configuration = {
64
57
writeFiles ( response . images ) ;
65
58
writeFiles ( response . files ) ;
66
59
67
- fs . writeFileSync ( path . resolve ( 'public' , 'favicon.html' ) , response . html . join ( '\n' ) ) ;
68
- } ;
69
-
70
- favicons ( icon , configuration , callback ) ;
60
+ fs . writeFileSync (
61
+ path . resolve ( 'public' , 'favicon.html' ) ,
62
+ response . html . join ( '\n' ) ,
63
+ ) ;
64
+ } )
65
+ . catch ( ( error ) => {
66
+ console . log ( error ) ;
67
+ } ) ;
0 commit comments