2
2
3
3
/* eslint-disable no-console,@typescript-eslint/no-magic-numbers */
4
4
import * as fs from 'node:fs' ;
5
+ import { copyFileSync } from 'node:fs' ;
5
6
import { spawnSync } from 'node:child_process' ;
6
7
import { Command } from 'commander' ;
7
8
import chalk from 'chalk' ;
@@ -12,6 +13,9 @@ const program = new Command();
12
13
13
14
const BUILD_ALL = 'all' ;
14
15
16
+ // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle
17
+ const __dirname = new URL ( '.' , import . meta. url ) . pathname ;
18
+
15
19
const zipFolder = ( source : string , dest : string ) : Promise < void > => {
16
20
const archive = archiver ( 'zip' , { zlib : { level : 9 } } ) ;
17
21
const stream = fs . createWriteStream ( dest ) ;
@@ -54,7 +58,7 @@ const callback = async (platform: string, {environment, watch, zip}) => {
54
58
command . push ( '--watch' ) ;
55
59
}
56
60
57
- return spawnSync ( 'npx' , command , {
61
+ const viteCommand = spawnSync ( 'npx' , command , {
58
62
stdio : 'inherit' ,
59
63
cwd : process . cwd ( ) ,
60
64
env : {
@@ -63,6 +67,24 @@ const callback = async (platform: string, {environment, watch, zip}) => {
63
67
PLATFORM : platform ,
64
68
} ,
65
69
} ) ;
70
+
71
+ /**
72
+ * @TODO : find better way to get these icons into the bundle
73
+ */
74
+ const ADDITIONAL_ICONS = Object . freeze ( [
75
+ `icon-${ platform } -16px-alt.png` ,
76
+ `icon-${ platform } -48px-alt.png` ,
77
+ `icon-${ platform } -128px-alt.png` ,
78
+ ] ) ;
79
+
80
+ const sourceIconDir = `${ __dirname } /../assets/icons/` ;
81
+ const destIconDir = `${ __dirname } /../dist/${ buildName } /assets/icons/` ;
82
+
83
+ ADDITIONAL_ICONS . forEach ( ( icon ) => {
84
+ copyFileSync ( `${ sourceIconDir } ${ icon } ` , `${ destIconDir } ${ icon } ` ) ;
85
+ } ) ;
86
+
87
+ return viteCommand ;
66
88
} ) ,
67
89
) ;
68
90
0 commit comments