Skip to content

Commit

Permalink
Merge pull request #20 from Lazyt3ch/master
Browse files Browse the repository at this point in the history
Code refactoring and two broken links fixing
  • Loading branch information
TheTechsTech authored Jan 11, 2023
2 parents 3aac6cd + 288e89e commit 58430af
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 241 deletions.
10 changes: 5 additions & 5 deletions installer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ const windowsPlatform = {
};

const windowsOtherPlatform = {
source: join(cwd, '7z1701.exe'),
source: join(cwd, '7z1604.exe'),
destination: join(cwd, 'other32'),
url: 'https://d.7-zip.org/a/',
filename: '7z1701.exe',
extraName: '7z1701-extra.7z',
url: 'https://www.7-zip.org/a/',
filename: '7z1604.exe',
extraName: '7z1604-extra.7z',
extractFolder: '',
appLocation: '',
binaryFiles: ['7z.exe', '7z.dll', '7z.sfx', '7zCon.sfx'],
binaryDestinationDir: join(__dirname, 'binaries', 'win32', 'other32'),
sfxModules: ['7za.dll', '7za.exe', '7zxa.dll'],
platform: 'win32',
binary: '7z.exe',
extraSourceFile: join(cwd, 'other32', '7z1701-extra.7z'),
extraSourceFile: join(cwd, 'other32', '7z1604-extra.7z'),
};

const linuxPlatform = {
Expand Down
67 changes: 37 additions & 30 deletions src/createSfx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ export function createSfx(
reject: (err: string) => void,
progress: (data: any) => any
) {
let directory =
destination != '' && fs.existsSync(destination)
? destination
: getPath('when');
let directory = undefined;
if (destination && fs.existsSync(destination))
directory = destination;
else {
const whenPath = getPath('when');
if (!whenPath) return reject('Path not found!');
directory = whenPath;
}

let SfxDirectory = join(directory, 'SfxPackages');
fs.ensureDirSync(SfxDirectory);
let override =
isWindows() && (platform == 'linux' || platform == 'darwin');
const override = isWindows() && ['linux', 'darwin'].includes(platform);
let binaryDirectory = Binary(override);
let configFile = join(binaryDirectory.path, 'config.txt');
//let configFile = join(SfxDirectory, 'config.txt');
Expand All @@ -166,24 +170,29 @@ export function createSfx(
if (text) config.write('ExecuteParameters=' + text + '\n');
config.write(';!@InstallEnd@!' + '\n');
config.close();
delete options.title;
delete options.prompt;
delete options.beginPrompt;
delete options.progress;
delete options.run;
delete options.runProgram;
delete options.directory;
delete options.execute;
delete options.executeFile;
delete options.parameters;
delete options.executeParameters;
let sfxModule =
type == 'gui' ? '7zwin32.sfx' : '7zCon' + platform + '.sfx';
let sfx = name.includes(extension) ? name : name + extension;
let list = Array.isArray(files)
? [configFile].concat(files)
: configFile + ' ' + files;
sfx = join(SfxDirectory, sfx);
[
'title',
'prompt',
'beginPrompt',
'progress',
'run',
'runProgram',
'directory',
'execute',
'executeFile',
'parameters',
'executeParameters'
].forEach((name) => delete options[name]);
const sfxModule = type === 'gui'
? '7zwin32.sfx'
: `7zCon${platform}.sfx`;
const sfxFilename = name.includes(extension)
? name
: name + extension;
const sfx = join(SfxDirectory, sfxFilename);
let list = Array.isArray(files)
? [configFile, ...files]
: `${configFile} ${files}`;
let params = Object.assign(options, {
sfx: sfxModule,
});
Expand All @@ -198,12 +207,10 @@ export function createSfx(
if (fs.existsSync(sfx)) {
return resolve(sfx);
/* c8 ignore next 4 */
} else {
console.error(data);
return reject(
'Failed! The Sfx application could not be created!'
);
}
}

console.error(data);
return reject('Failed! The Sfx application could not be created!');
});
})
.catch((err: string) => {
Expand Down
Loading

0 comments on commit 58430af

Please sign in to comment.