Skip to content

Commit 16af420

Browse files
committed
Fix native WordPress CI service mounts
1 parent f9813f0 commit 16af420

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

.github/workflows/wp-tests-phpunit-native-extension-setup.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,25 @@ const service = process.argv[3];
2626
const volume = process.argv[4];
2727
const lines = fs.readFileSync( file, 'utf8' ).split( '\n' );
2828
29-
if ( lines.some( line => line.trim() === volume.trim() ) ) {
30-
process.exit( 0 );
31-
}
32-
3329
const serviceIndex = lines.findIndex( line => line === ` ${ service }:` );
3430
if ( serviceIndex === -1 ) {
3531
throw new Error( `Service ${ service } not found in ${ file }.` );
3632
}
3733
38-
let volumesIndex = -1;
34+
let serviceEnd = lines.length;
3935
for ( let i = serviceIndex + 1; i < lines.length; i++ ) {
4036
if ( /^ [A-Za-z0-9_-]+:/.test( lines[i] ) ) {
37+
serviceEnd = i;
4138
break;
4239
}
40+
}
4341
42+
if ( lines.slice( serviceIndex, serviceEnd ).some( line => line.trim() === volume.trim() ) ) {
43+
process.exit( 0 );
44+
}
45+
46+
let volumesIndex = -1;
47+
for ( let i = serviceIndex + 1; i < serviceEnd; i++ ) {
4448
if ( lines[i].trim() === 'volumes:' ) {
4549
volumesIndex = i;
4650
break;
@@ -52,7 +56,7 @@ if ( volumesIndex === -1 ) {
5256
}
5357
5458
let insertAt = volumesIndex + 1;
55-
while ( insertAt < lines.length && /^\s{6}- /.test( lines[insertAt] ) ) {
59+
while ( insertAt < serviceEnd && /^\s{6}- /.test( lines[insertAt] ) ) {
5660
insertAt++;
5761
}
5862

0 commit comments

Comments
 (0)