Skip to content

Commit

Permalink
allow mocking out
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Mar 11, 2024
1 parent 0ac258f commit 1f95f62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions starskydesktop/jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
'!runtime-starsky-win-x64/**',
'!runtime-starsky-mac-arm64/**',
'!runtime-starsky-linux-x64/**',
'!src/setup/**',
'!dist/**',
'!dist-prod/**',
],
Expand Down
20 changes: 13 additions & 7 deletions starskydesktop/src/app/child-process/spawn-clean-mac-os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ import { spawn } from "child_process";
import * as path from "path";
import logger from "../logger/logger";

function executeXattrCommand(appStarskyPath: string): Promise<void> {
export function ExecuteXattrCommand(
appStarskyPath: string,
xattr: string = "xattr"
): Promise<void> {
return new Promise((resolve, reject) => {
const xattrArgs = ["-rd", "com.apple.quarantine", appStarskyPath];
const xattrOptions = {
detached: true,
env: process.env,
argv0: "xattr",
argv0: xattr,
};

const xattrChild = spawn("xattr", xattrArgs, xattrOptions);
const xattrChild = spawn(xattr, xattrArgs, xattrOptions);

xattrChild.on("error", (err) => {
logger.info("Error occurred while running xattr command:", err);
Expand All @@ -30,7 +33,10 @@ function executeXattrCommand(appStarskyPath: string): Promise<void> {
});
}

function executeCodesignCommand(appStarskyPath: string): Promise<void> {
export function ExecuteCodesignCommand(
appStarskyPath: string,
codesign: string = "codesign"
): Promise<void> {
return new Promise((resolve, reject) => {
const args = [
"--force",
Expand All @@ -44,10 +50,10 @@ function executeCodesignCommand(appStarskyPath: string): Promise<void> {
cwd: path.dirname(appStarskyPath),
detached: true,
env: process.env,
argv0: "codesign",
argv0: codesign,
};

const codeSignSpawn = spawn("codesign", args, options);
const codeSignSpawn = spawn(codesign, args, options);

codeSignSpawn.on("exit", (code) => {
logger.info(`code sign EXIT: CODE: ${code}`);
Expand All @@ -74,7 +80,7 @@ export function SpawnCleanMacOs(appStarskyPath: string, processPlatform: string)
resolve(true);
}

Promise.all([executeXattrCommand(appStarskyPath), executeCodesignCommand(appStarskyPath)])
Promise.all([ExecuteXattrCommand(appStarskyPath), ExecuteCodesignCommand(appStarskyPath)])
.then(() => {
resolve(true);
})
Expand Down

0 comments on commit 1f95f62

Please sign in to comment.