Skip to content

Commit

Permalink
rename createTestApp to createStagingAppDir and add jsdoc to the …
Browse files Browse the repository at this point in the history
…function
  • Loading branch information
mmaietta committed Feb 23, 2025
1 parent 61abfd3 commit 67a8437
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 9 additions & 7 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path';

import { makeUniversalApp } from '../dist/cjs/index';
import {
createTestApp,
createStagingAppDir,
generateNativeApp,
templateApp,
VERIFY_APP_TIMEOUT,
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('makeUniversalApp', () => {
'should not inject ElectronAsarIntegrity into `infoPlistsToIgnore`',
async () => {
const arm64AppPath = await templateApp('Arm64-1.app', 'arm64', async (appPath) => {
const { testPath } = await createTestApp('Arm64-1');
const { testPath } = await createStagingAppDir('Arm64-1');
await createPackage(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app.asar'));
await templateApp('SubApp-1.app', 'arm64', async (subArm64AppPath) => {
await fs.move(
Expand All @@ -160,7 +160,7 @@ describe('makeUniversalApp', () => {
});
});
const x64AppPath = await templateApp('X64-1.app', 'x64', async (appPath) => {
const { testPath } = await createTestApp('X64-1');
const { testPath } = await createStagingAppDir('X64-1');
await createPackage(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app.asar'));
await templateApp('SubApp-1.app', 'x64', async (subArm64AppPath) => {
await fs.move(
Expand All @@ -186,7 +186,7 @@ describe('makeUniversalApp', () => {
'should shim asars with different unpacked dirs',
async () => {
const arm64AppPath = await templateApp('UnpackedArm64.app', 'arm64', async (appPath) => {
const { testPath } = await createTestApp('UnpackedAppArm64');
const { testPath } = await createStagingAppDir('UnpackedAppArm64');
await createPackageWithOptions(
testPath,
path.resolve(appPath, 'Contents', 'Resources', 'app.asar'),
Expand All @@ -198,7 +198,7 @@ describe('makeUniversalApp', () => {
});

const x64AppPath = await templateApp('UnpackedX64.app', 'x64', async (appPath) => {
const { testPath } = await createTestApp('UnpackedAppX64');
const { testPath } = await createStagingAppDir('UnpackedAppX64');
await createPackageWithOptions(
testPath,
path.resolve(appPath, 'Contents', 'Resources', 'app.asar'),
Expand Down Expand Up @@ -237,14 +237,16 @@ describe('makeUniversalApp', () => {
'should shim two different app folders',
async () => {
const arm64AppPath = await templateApp('ShimArm64.app', 'arm64', async (appPath) => {
const { testPath } = await createTestApp('shimArm64', {
const { testPath } = await createStagingAppDir('shimArm64', {
'i-aint-got-no-rhythm.bin': 'boomshakalaka',
});
await fs.copy(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app'));
});

const x64AppPath = await templateApp('ShimX64.app', 'x64', async (appPath) => {
const { testPath } = await createTestApp('shimX64', { 'hello-world.bin': 'Hello World' });
const { testPath } = await createStagingAppDir('shimX64', {
'hello-world.bin': 'Hello World',
});
await fs.copy(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app'));
});

Expand Down
8 changes: 6 additions & 2 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export const removeUnstableProperties = (data: any) => {
};

/**
* Creates an app directory at runtime for usage:
* - `testPath` can be used with `asar.createPackage`. Just set the output `.asar` path to `Test.app/Contents/Resources/<asar_name>.asar`
* - `testPath` can be utilized for logic paths involving `AsarMode.NO_ASAR` and copied directly to `Test.app/Contents/Resources`
*
* Directory structure:
* testName
* ├── private
Expand All @@ -127,7 +131,7 @@ export const removeUnstableProperties = (data: any) => {
* ├── index.js
* ├── package.json
*/
export const createTestApp = async (
export const createStagingAppDir = async (
testName: string | undefined,
additionalFiles: Record<string, string> = {},
) => {
Expand Down Expand Up @@ -202,7 +206,7 @@ export const generateNativeApp = async (options: {
if (!fs.existsSync(resourcesApp)) {
await fs.mkdir(resourcesApp);
}
const { testPath } = await createTestApp(
const { testPath } = await createStagingAppDir(
path.basename(appNameWithExtension, '.app'),
additionalFiles,
);
Expand Down

0 comments on commit 67a8437

Please sign in to comment.