Skip to content

Commit

Permalink
Tweak location of shared function
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonpayton committed Oct 8, 2024
1 parent 51dd315 commit 3b1cffd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
15 changes: 0 additions & 15 deletions packages/playground/wordpress/src/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,3 @@ export function getFileNotFoundActionForWordPress(
uri: '/index.php',
};
}

/**
* Check if the given directory handle directory is a Playground directory.
*
* @param fileExists Function A function that checks if a file exists relative to an assumed directory.
* @returns Promise<boolean> Whether the directory looks like a Playground directory.
*/
export async function looksLikePlaygroundDirectory(
fileExists: (relativePath: string) => Promise<boolean>
) {
const results = await Promise.all(
['wp-config.php', 'wp-content/database/.ht.sqlite'].map(fileExists)
);
return results.every(Boolean);
}
21 changes: 16 additions & 5 deletions packages/playground/wordpress/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { PHP, UniversalPHP } from '@php-wasm/universal';
import { joinPaths, phpVar } from '@php-wasm/util';
import { unzipFile } from '@wp-playground/common';
export {
bootWordPress,
getFileNotFoundActionForWordPress,
looksLikePlaygroundDirectory,
} from './boot';
export { bootWordPress, getFileNotFoundActionForWordPress } from './boot';
export { getLoadedWordPressVersion } from './version-detect';

export * from './version-detect';
Expand Down Expand Up @@ -388,6 +384,21 @@ export async function unzipWordPress(php: PHP, wpZip: File) {
}
}

/**
* Check if the given directory handle directory is a Playground directory.
*
* @param fileExists Function A function that checks if a file exists relative to an assumed directory.
* @returns Promise<boolean> Whether the directory looks like a Playground directory.
*/
export async function looksLikePlaygroundDirectory(
fileExists: (relativePath: string) => Promise<boolean>
) {
const results = await Promise.all(
['wp-config.php', 'wp-content/database/.ht.sqlite'].map(fileExists)
);
return results.every(Boolean);
}

function isCleanDirContainingSiteMetadata(path: string, php: PHP) {
const files = php.listFiles(path);
if (files.length === 0) {
Expand Down

0 comments on commit 3b1cffd

Please sign in to comment.