elementor
Last commit date
app
1 year ago
assets
1 year ago
core
1 year ago
data
3 years ago
includes
1 year ago
modules
1 year ago
changelog.txt
1 year ago
elementor.php
1 year ago
license.txt
3 years ago
phpcs.xml
3 years ago
readme.txt
1 year ago
run-on-linux.js
2 years ago
tsconfig.json
2 years ago
run-on-linux.js
45 lines
| 1 | const { spawn, exec } = require( 'child_process' ); |
| 2 | const packageJson = require( './package.json' ); |
| 3 | |
| 4 | function isDockerExist() { |
| 5 | return new Promise( ( resolve ) => { |
| 6 | exec( 'docker -v', ( error ) => { |
| 7 | resolve( ! error ); |
| 8 | } ); |
| 9 | } ); |
| 10 | } |
| 11 | |
| 12 | async function run( tag ) { |
| 13 | const playwrightVersion = packageJson.devDependencies[ '@playwright/test' ]; |
| 14 | const workingDir = process.cwd(); |
| 15 | |
| 16 | const command = 'docker run'; |
| 17 | const options = [ |
| 18 | '--rm', |
| 19 | '--network host', |
| 20 | `--volume ${ workingDir }:/work`, |
| 21 | '--workdir /work/', |
| 22 | '--interactive', |
| 23 | process.env.CI ? '' : '--tty', |
| 24 | ]; |
| 25 | const image = `mcr.microsoft.com/playwright:v${ playwrightVersion.replace( '^', '' ) }-jammy`; |
| 26 | const commandToRun = `/bin/bash -c "npm run test:playwright -- --grep="${ tag }""`; |
| 27 | |
| 28 | spawn( `${ command } ${ options.join( ' ' ) } ${ image } ${ commandToRun }`, { |
| 29 | stdio: 'inherit', |
| 30 | stderr: 'inherit', |
| 31 | shell: true, |
| 32 | } ); |
| 33 | } |
| 34 | |
| 35 | ( async () => { |
| 36 | if ( ! await isDockerExist() ) { |
| 37 | // eslint-disable-next-line no-console |
| 38 | console.error( 'Docker is not installed, please install it first.' ); |
| 39 | |
| 40 | process.exit( 1 ); |
| 41 | } |
| 42 | |
| 43 | await run( process.argv.slice( 2 ) ); |
| 44 | } )(); |
| 45 |