Skip to content

Commit 657564d

Browse files
feat: use wait-on instead of wait-for
1 parent 0544d62 commit 657564d

File tree

5 files changed

+27
-200
lines changed

5 files changed

+27
-200
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"countries-list": "^3.1.1",
1414
"knex": "^3.1.0",
1515
"lodash": "^4.17.21",
16-
"mysql": "^2.18.1"
16+
"mysql": "^2.18.1",
17+
"wait-on": "^9.0.1"
1718
},
1819
"devDependencies": {
1920
"@martin-kolarik/eslint-config": "^8.0.4",

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/init.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if [[ ("$DIRECTUS_URL" != *"localhost"* && "$DIRECTUS_URL" != *"127.0.0.1"*) ||
4545
exit 1
4646
fi
4747

48-
./scripts/wait-for.sh -t 30 $DIRECTUS_URL/admin/login
48+
npx wait-on -t 30s -l "$DIRECTUS_URL/admin/login"
4949

5050
token=$(get_token)
5151

@@ -70,6 +70,6 @@ docker compose --file "$compose_file" stop directus
7070

7171
docker compose --file "$compose_file" up -d directus
7272

73-
./scripts/wait-for.sh -t 30 $DIRECTUS_URL/admin/login
73+
npx wait-on -t 30s -l "$DIRECTUS_URL/admin/login"
7474

7575
echo "Finished"

scripts/wait-for.sh

Lines changed: 0 additions & 194 deletions
This file was deleted.

test/e2e/global.setup.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ import pm2, { StartOptions } from 'pm2';
22
import { execa } from 'execa';
33
import { test as setup } from '@playwright/test';
44
import { promisify } from 'util';
5+
import waitOn from 'wait-on';
56

67
const DIRECTUS_URL = process.env.DIRECTUS_URL!;
78
const DASH_URL = process.env.DASH_URL!;
89
const DASH_INDEX_FILE_PATH = process.env.DASH_INDEX_FILE_PATH!;
910

1011
const pm2Start = promisify(pm2.start.bind(pm2)) as (options: StartOptions) => Promise<void>;
1112

12-
const waitFor = (url: string, timeout = 30) => execa({ stdout: 'inherit' })`./scripts/wait-for.sh -t ${timeout} ${url}`;
13+
const waitFor = (url: string, timeout = 30000) => waitOn({ resources: [ url ], timeout });
14+
1315

1416
const getIsRunning = async (url: string) => {
1517
try {
16-
await waitFor(url, 2);
18+
await waitFor(url, 2000);
1719
console.log(`Service at ${url} is already running.`);
1820
return true;
1921
} catch (err) {
20-
if (err.stderr === 'Operation timed out') {
22+
if (err.message.includes('Timed out')) {
2123
console.log(`Service at ${url} not running. Starting...`);
2224
} else {
2325
throw err;

0 commit comments

Comments
 (0)