tachybase_todo/scripts/codegen.setup.ts
被雨水过滤的空气-Rain 887ddf0ed1
test: optimize command (#3030)
* test: optimize command

* chore: add force options

* chore: kill child process
2023-11-14 10:04:09 +08:00

33 lines
810 B
TypeScript

import { execSync } from 'node:child_process';
import { APP_BASE_URL, commonConfig, runNocoBase } from './utils';
const runCodegenSync = () => {
try {
execSync(
`npx playwright codegen --load-storage=playwright/.auth/codegen.auth.json ${APP_BASE_URL} --save-storage=playwright/.auth/codegen.auth.json`,
commonConfig,
);
} catch (err) {
if (err.message.includes('auth.json')) {
execSync(
`npx playwright codegen ${APP_BASE_URL} --save-storage=playwright/.auth/codegen.auth.json`,
commonConfig,
);
} else {
console.error(err);
}
}
};
const run = async () => {
const { kill, awaitForNocoBase } = await runNocoBase();
await awaitForNocoBase();
console.log('Starting codegen...');
runCodegenSync();
kill?.('SIGKILL');
};
run();