@@ -6,12 +6,12 @@ import { fileURLToPath } from 'url';
6
6
import { dirname , sep , join } from 'path' ;
7
7
import fs from 'fs-extra' ;
8
8
import { Binary } from './utility' ;
9
- import { isArray , isWindows } from 'node-sys' ;
9
+ import { isWindows } from 'node-sys' ;
10
10
const platformTitle = {
11
11
win32 : 'Windows OS' ,
12
12
darwin : 'Apple macOS' ,
13
13
linux : 'Linux OS' ,
14
- } ;
14
+ } as Record < NodeJS . Platform , string > ;
15
15
const title =
16
16
' installation package created on ' + platformTitle [ process . platform ] + '.' ;
17
17
const prompt = 'Do you want to install ' ;
@@ -24,7 +24,7 @@ const __dirname = dirname(__filename);
24
24
const pwd = __dirname . split ( sep ) ;
25
25
26
26
/* c8 ignore next 18 */
27
- function getPath ( module , folder = pwd ) {
27
+ function getPath ( module : string , folder = pwd ) : string | null {
28
28
if ( folder . length < 1 ) {
29
29
return null ;
30
30
}
@@ -115,20 +115,24 @@ archive.pipe(SfxDirectory, {
115
115
*
116
116
* @returns {Promise } Promise
117
117
*/
118
- export const createSfx = function (
119
- name : String ,
120
- files : Array ,
121
- destination : String = '' ,
122
- options : { } = {
118
+ export function createSfx (
119
+ name : string ,
120
+ files : Array < string > ,
121
+ destination : string = '' ,
122
+ options : Record < string , any > = {
123
123
title : null ,
124
124
beginPrompt : null ,
125
125
progress : null ,
126
126
} ,
127
- type : String = 'gui' ,
128
- platform : String = 'win32' ,
129
- extension : String = '.exe'
130
- ) : Promise {
131
- return when . promise ( function ( resolve , reject , progress ) {
127
+ type : string = 'gui' ,
128
+ platform : string = 'win32' ,
129
+ extension : string = '.exe'
130
+ ) {
131
+ return when . promise ( function (
132
+ resolve : ( arg0 : string ) => void ,
133
+ reject : ( arg0 : string ) => void ,
134
+ progress : ( arg0 : any ) => any
135
+ ) {
132
136
let directory =
133
137
destination != '' && fs . existsSync ( destination )
134
138
? destination
@@ -176,18 +180,18 @@ export const createSfx = function (
176
180
let sfxModule =
177
181
type == 'gui' ? '7zwin32.sfx' : '7zCon' + platform + '.sfx' ;
178
182
let sfx = name . includes ( extension ) ? name : name + extension ;
179
- let list = isArray ( files )
183
+ let list = Array . isArray ( files )
180
184
? [ configFile ] . concat ( files )
181
185
: configFile + ' ' + files ;
182
186
sfx = join ( SfxDirectory , sfx ) ;
183
187
let params = Object . assign ( options , {
184
188
sfx : sfxModule ,
185
189
} ) ;
186
190
createArchive ( sfx , list , params , override )
187
- . progress ( ( data ) => {
191
+ . progress ( ( data : any ) => {
188
192
return progress ( data ) ;
189
193
} )
190
- . then ( ( data ) => {
194
+ . then ( ( data : any ) => {
191
195
fs . unlink ( configFile , ( err ) => {
192
196
if ( err ) console . error ( err ) ;
193
197
@@ -202,9 +206,9 @@ export const createSfx = function (
202
206
}
203
207
} ) ;
204
208
} )
205
- . catch ( ( err ) => {
209
+ . catch ( ( err : string ) => {
206
210
fs . removeSync ( configFile ) ;
207
211
return reject ( err ) ;
208
212
} ) ;
209
213
} ) ;
210
- } ;
214
+ }
0 commit comments