Skip to content

Commit

Permalink
feat: solving an issue with the getNoPlatformInfo function
Browse files Browse the repository at this point in the history
  • Loading branch information
robherba committed Sep 10, 2024
1 parent fc7b8a3 commit 40cbce7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/util/platform/getNoPlatformInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ describe('getNoPlatformInfo', () => {
await expect(getNoPlatformInfo()).resolves.toEqual({
name: 'none',
platformMajorVersion: 1,
emulsifyParentDirectory: '/home/uname/Projects/cornflake',
root: '/home/uname/Projects/cornflake/',
emulsifyParentDirectory:
'/home/uname/Projects/cornflake/web/themes/custom',
root: '/home/uname/Projects/cornflake',
});
});

it('returns void if no project.emulsify.json file is found', async () => {
expect.assertions(1);
findFileMock.mockReturnValueOnce(undefined);
await expect(getNoPlatformInfo()).resolves.toBe(undefined);
await expect(getNoPlatformInfo()).resolves.toBeUndefined();
});
});
11 changes: 4 additions & 7 deletions src/util/platform/getNoPlatformInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { PlatformInstanceInfo } from '@emulsify-cli/internal';
import { resolve } from 'path';
import { dirname, join } from 'path';
import findFileInCurrentPath from '../fs/findFileInCurrentPath.js';
import { resolveCurrentPath } from '../fs/resolveCurrentPath.js';
import type { PlatformInstanceInfo } from '@emulsify-cli/internal';

/**
* Looks for no platform specified within the cwd, and returns information
Expand All @@ -12,13 +11,11 @@ export default async function getNoPlatformInfo(): Promise<PlatformInstanceInfo
if (!existingProject) {
return undefined;
}
const { directoryPath } = resolveCurrentPath();
const root = resolve(directoryPath);

const root = dirname(existingProject);
return {
root,
name: 'none',
emulsifyParentDirectory: root,
emulsifyParentDirectory: join(root, 'web', 'themes', 'custom'),
platformMajorVersion: 1,
};
}
2 changes: 1 addition & 1 deletion src/util/platform/getPlatformInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PlatformInstanceInfo } from '@emulsify-cli/internal';

import getDrupalInfo from './getDrupalInfo.js';
import getNoPlatformInfo from './getNoPlatformInfo';
import getNoPlatformInfo from './getNoPlatformInfo.js';

/**
* Returns information about the platform the user is currently within (cwd), if it
Expand Down

0 comments on commit 40cbce7

Please sign in to comment.