Skip to content

Commit

Permalink
Lint: Remove unused variables and code
Browse files Browse the repository at this point in the history
  • Loading branch information
eliot-akira committed Sep 12, 2024
1 parent 2ad15cc commit f9e5690
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
20 changes: 2 additions & 18 deletions packages/wp-now/src/execute-wp-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import getWpNowConfig from './config';
import { DEFAULT_PHP_VERSION, DEFAULT_WORDPRESS_VERSION } from './constants';
import { phpVar } from '@php-wasm/util';
import { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';
// import { getSqliteCommandPath } from '../../../src/lib/sqlite-command-versions';
import {
PHP,
MountHandler,
writeFiles,
setPhpIniEntries,
loadPHPRuntime,
} from '@php-wasm/universal';
import { readFileSync } from 'fs';

Expand All @@ -21,11 +19,9 @@ const isWindows = process.platform === 'win32';
* This is an unstable API. Multiple wp-cli commands may not work due to a current limitation on php-wasm and pthreads.
*/
export async function executeWPCli(
projectPath: string,
args: string[],
{
phpVersion,
projectPath,
}: { phpVersion?: string; projectPath?: string } = {}
{ phpVersion }: { phpVersion?: string } = {}
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
await downloadWPCLI();
const options = await getWpNowConfig({
Expand All @@ -49,7 +45,6 @@ export async function executeWPCli(

const wpCliPath = '/tmp/wp-cli.phar';
const stderrPath = '/tmp/stderr';
const sqliteCommandPath = '/tmp/sqlite-command';
const runCliPath = '/tmp/run-cli.php';
const createFiles = {
[wpCliPath]: readFileSync(getWpCliPath()),
Expand Down Expand Up @@ -99,17 +94,6 @@ export async function executeWPCli(
await setPhpIniEntries(php, {
'openssl.cafile': '/internal/shared/ca-bundle.crt',
});
// try {
// php.mkdir(sqliteCommandPath);
// await php.mount(
// sqliteCommandPath,
// createNodeFsMountHandler(
// getSqliteCommandPath()
// ) as unknown as MountHandler
// );
// } catch (e) {
// console.log(e);
// }

try {
php.chdir(options.documentRoot);
Expand Down
16 changes: 3 additions & 13 deletions packages/wp-now/src/wp-now.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { rootCertificates } from 'tls';
import fs, { copySync } from 'fs-extra';
import fs from 'fs-extra';
import { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';
import {
PHP,
Expand Down Expand Up @@ -61,17 +61,9 @@ export default async function startWPNow(
): Promise<{ php: PHP; options: WPNowOptions }> {
const { documentRoot } = options;

// Similar logic as bootWordPress() in @wp-playground/wordpess

const createPhpRuntime = async () =>
await loadNodeRuntime(options.phpVersion);
const requestHandler = new PHPRequestHandler({
phpFactory: async ({ isPrimary, requestHandler }) => {
const { php, runtimeId } = await getPHPInstance(
options,
isPrimary,
requestHandler
);
const { php } = await getPHPInstance(options);

if (requestHandler) {
php.requestHandler = requestHandler;
Expand Down Expand Up @@ -193,9 +185,7 @@ export default async function startWPNow(
}

async function getPHPInstance(
options: WPNowOptions,
isPrimary: boolean,
requestHandler: PHPRequestHandler
options: WPNowOptions
): Promise<{ php: PHP; runtimeId: number }> {
const id = await loadNodeRuntime(options.phpVersion);
const php = new PHP(id);
Expand Down

0 comments on commit f9e5690

Please sign in to comment.