diff --git a/index.js b/index.js index b8c9820..05989c3 100755 --- a/index.js +++ b/index.js @@ -37,6 +37,7 @@ const scripts = { "env": "wp-env", "env:start": "wp-env start", "env:stop": "wp-env stop", + "env:destroy": "wp-env destroy", "postenv:start": "./tests/bin/initialize.sh", }; diff --git a/src/tests/bin/initialize.sh b/src/tests/bin/initialize.sh index 9d06a85..51ba8ea 100755 --- a/src/tests/bin/initialize.sh +++ b/src/tests/bin/initialize.sh @@ -1,3 +1,3 @@ #!/bin/bash -npm run env run tests-wordpress "chmod -c ugo+w /var/www/html" -npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard" +npm run env run tests-wordpress chmod -- -c ugo+w /var/www/html +npm run env run tests-cli wp rewrite structure '/%postname%/' -- --hard diff --git a/src/tests/cypress/config.js b/src/tests/cypress/config.js index 297c75b..e620727 100644 --- a/src/tests/cypress/config.js +++ b/src/tests/cypress/config.js @@ -1,5 +1,6 @@ const { defineConfig } = require('cypress'); -const { readConfig } = require('@wordpress/env/lib/config'); +const { loadConfig } = require( '@wordpress/env/lib/config' ); +const getCacheDirectory = require( '@wordpress/env/lib/config/get-cache-directory' ); module.exports = defineConfig({ fixturesFolder: 'tests/cypress/fixtures', @@ -18,13 +19,14 @@ module.exports = defineConfig({ /** * Set WP URL as baseUrl in Cypress config. - * + * * @param {Function} on function that used to register listeners on various events. * @param {object} config Cypress Config object. * @returns config Updated Cypress Config object. */ const setBaseUrl = async (on, config) => { - const wpEnvConfig = await readConfig('wp-env'); + const cacheDirectory = await getCacheDirectory(); + const wpEnvConfig = await loadConfig( cacheDirectory ); if (wpEnvConfig) { const port = wpEnvConfig.env.tests.port || null;