2020-04-02 13:41:06 +00:00
|
|
|
const path = require( 'path' );
|
|
|
|
|
|
|
|
const getAppRoot = () => {
|
|
|
|
// Figure out where we're installed.
|
2020-04-28 20:14:11 +00:00
|
|
|
// Typically will be in node_modules/, but WooCommerce
|
|
|
|
// uses a local file path (tests/e2e/env).
|
2020-04-02 13:41:06 +00:00
|
|
|
let appPath = false;
|
2020-04-30 17:01:42 +00:00
|
|
|
const moduleDir = path.dirname( require.resolve( '@woocommerce/e2e-environment' ) );
|
2020-04-02 13:41:06 +00:00
|
|
|
|
|
|
|
if ( -1 < moduleDir.indexOf( 'node_modules' ) ) {
|
|
|
|
appPath = moduleDir.split( 'node_modules' )[ 0 ];
|
2020-04-28 20:14:11 +00:00
|
|
|
} else if ( -1 < moduleDir.indexOf( 'tests/e2e/env' ) ) {
|
|
|
|
appPath = moduleDir.split( 'tests/e2e/env' )[ 0 ];
|
2020-04-02 13:41:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return appPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = getAppRoot;
|