'use strict';

import path from 'path'
import * as execa from 'execa'
import * as tools from '@eui/tools/scripts/utils/tools.js'

const inputArgs = tools.getArgs();

Promise.resolve()
  .then(() => {
    tools.logTitle('Execution starts...');
    tools.logInfo('Args provided : ');
    // console.log(inputArgs);

    const wdio = path.resolve(process.cwd(), 'node_modules', '@wdio', 'cli', 'bin', 'wdio.js');

    let args = [wdio, inputArgs.root, '--suite', inputArgs.suite];

    // tools.logInfo(`running wdio with args: ${args}`);

    return execa('node', args, { cwd: process.cwd(), stdio: 'inherit' });
  })
  .catch((e) => {
    tools.logError('ERROR!!!');
    console.error(e);
    process.exit(1);
  });
