Skip to content

Commit ecc86b7

Browse files
committed
fix: fix the type errors
1 parent f45abe4 commit ecc86b7

File tree

4 files changed

+196
-108
lines changed

4 files changed

+196
-108
lines changed

src/createSfx.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { fileURLToPath } from 'url';
66
import { dirname, sep, join } from 'path';
77
import fs from 'fs-extra';
88
import { Binary } from './utility';
9-
import { isArray, isWindows } from 'node-sys';
9+
import { isWindows } from 'node-sys';
1010
const platformTitle = {
1111
win32: 'Windows OS',
1212
darwin: 'Apple macOS',
1313
linux: 'Linux OS',
14-
};
14+
} as Record<NodeJS.Platform, string>;
1515
const title =
1616
' installation package created on ' + platformTitle[process.platform] + '.';
1717
const prompt = 'Do you want to install ';
@@ -24,7 +24,7 @@ const __dirname = dirname(__filename);
2424
const pwd = __dirname.split(sep);
2525

2626
/* c8 ignore next 18 */
27-
function getPath(module, folder = pwd) {
27+
function getPath(module: string, folder = pwd): string | null {
2828
if (folder.length < 1) {
2929
return null;
3030
}
@@ -115,20 +115,24 @@ archive.pipe(SfxDirectory, {
115115
*
116116
* @returns {Promise} Promise
117117
*/
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> = {
123123
title: null,
124124
beginPrompt: null,
125125
progress: null,
126126
},
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+
) {
132136
let directory =
133137
destination != '' && fs.existsSync(destination)
134138
? destination
@@ -176,18 +180,18 @@ export const createSfx = function (
176180
let sfxModule =
177181
type == 'gui' ? '7zwin32.sfx' : '7zCon' + platform + '.sfx';
178182
let sfx = name.includes(extension) ? name : name + extension;
179-
let list = isArray(files)
183+
let list = Array.isArray(files)
180184
? [configFile].concat(files)
181185
: configFile + ' ' + files;
182186
sfx = join(SfxDirectory, sfx);
183187
let params = Object.assign(options, {
184188
sfx: sfxModule,
185189
});
186190
createArchive(sfx, list, params, override)
187-
.progress((data) => {
191+
.progress((data: any) => {
188192
return progress(data);
189193
})
190-
.then((data) => {
194+
.then((data: any) => {
191195
fs.unlink(configFile, (err) => {
192196
if (err) console.error(err);
193197

@@ -202,9 +206,9 @@ export const createSfx = function (
202206
}
203207
});
204208
})
205-
.catch((err) => {
209+
.catch((err: string) => {
206210
fs.removeSync(configFile);
207211
return reject(err);
208212
});
209213
});
210-
};
214+
}

0 commit comments

Comments
 (0)