mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-05-24 02:08:24 +00:00
chore(podman): move getAssetsFolder to the utility (#1105)
chore: move getAssetsFolder to the utility Change-Id: I2c50ca9990f1fc31c2983ca188b1531f9c344e23 Signed-off-by: Florent Benoit <fbenoit@redhat.com> Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
parent
6ae90be73b
commit
3495e18235
2 changed files with 14 additions and 16 deletions
|
|
@ -26,7 +26,7 @@ import * as podmanTool from './podman.json';
|
|||
import type { InstalledPodman } from './podman-cli';
|
||||
import { execPromise } from './podman-cli';
|
||||
import { getPodmanInstallation } from './podman-cli';
|
||||
import { isDev, runCliCommand } from './util';
|
||||
import { getAssetsFolder, runCliCommand } from './util';
|
||||
import { getDetectionChecks } from './detection-checks';
|
||||
import { BaseCheck } from './base-check';
|
||||
import { MacCPUCheck, MacMemoryCheck, MacPodmanInstallCheck, MacVersionCheck } from './macos-checks';
|
||||
|
|
@ -250,16 +250,6 @@ abstract class BaseInstaller implements Installer {
|
|||
requireUpdate(installedVersion: string): boolean {
|
||||
return compare(installedVersion, getBundledPodmanVersion(), '<');
|
||||
}
|
||||
|
||||
protected getAssetsFolder(): string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
if (isDev()) {
|
||||
return path.resolve(__dirname, '..', 'assets');
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return path.resolve((process as any).resourcesPath, 'extensions', 'podman', 'assets');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WinInstaller extends BaseInstaller {
|
||||
|
|
@ -278,7 +268,7 @@ class WinInstaller extends BaseInstaller {
|
|||
install(): Promise<boolean> {
|
||||
return extensionApi.window.withProgress({ location: extensionApi.ProgressLocation.APP_ICON }, async progress => {
|
||||
progress.report({ increment: 5 });
|
||||
const setupPath = path.resolve(this.getAssetsFolder(), `podman-${podmanTool.version}-setup.exe`);
|
||||
const setupPath = path.resolve(getAssetsFolder(), `podman-${podmanTool.version}-setup.exe`);
|
||||
try {
|
||||
if (fs.existsSync(setupPath)) {
|
||||
const runResult = await runCliCommand(setupPath, ['/install', '/norestart']);
|
||||
|
|
@ -309,10 +299,7 @@ class MacOSInstaller extends BaseInstaller {
|
|||
progress.report({ increment: 5 });
|
||||
const pkgArch = process.arch === 'arm64' ? 'aarch64' : 'amd64';
|
||||
|
||||
const pkgPath = path.resolve(
|
||||
this.getAssetsFolder(),
|
||||
`podman-installer-macos-${pkgArch}-v${podmanTool.version}.pkg`,
|
||||
);
|
||||
const pkgPath = path.resolve(getAssetsFolder(), `podman-installer-macos-${pkgArch}-v${podmanTool.version}.pkg`);
|
||||
try {
|
||||
if (fs.existsSync(pkgPath)) {
|
||||
const runResult = await runCliCommand('open', [pkgPath, '-W']);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { getInstallationPath } from './podman-cli';
|
||||
|
||||
|
|
@ -43,6 +44,16 @@ export interface RunOptions {
|
|||
env?: NodeJS.ProcessEnv;
|
||||
}
|
||||
|
||||
export function getAssetsFolder(): string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
if (isDev()) {
|
||||
return path.resolve(__dirname, '..', 'assets');
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return path.resolve((process as any).resourcesPath, 'extensions', 'podman', 'assets');
|
||||
}
|
||||
}
|
||||
|
||||
export function runCliCommand(command: string, args: string[], options?: RunOptions): Promise<SpawnResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let output = '';
|
||||
|
|
|
|||
Loading…
Reference in a new issue