1919 */
2020
2121import * as vscode from 'vscode' ;
22- import { spawnSync } from 'child_process' ;
22+ import * as cp from 'child_process' ;
2323import * as fs from 'fs' ;
2424import * as path from 'path' ;
2525
26+ /**
27+ * System calls wrapper for testability
28+ */
29+ export const sys = {
30+ spawnSync : cp . spawnSync ,
31+ existsSync : fs . existsSync
32+ } ;
33+
2634/**
2735 * DDEV project validation result
2836 */
@@ -49,7 +57,7 @@ export class DdevUtils {
4957 public static hasDdevProject ( workspacePath : string ) : boolean {
5058 try {
5159 const configPath = path . join ( workspacePath , '.ddev' , 'config.yaml' ) ;
52- return fs . existsSync ( configPath ) ;
60+ return sys . existsSync ( configPath ) ;
5361 } catch ( error ) {
5462 return false ;
5563 }
@@ -63,7 +71,7 @@ export class DdevUtils {
6371 */
6472 public static isDdevRunning ( workspacePath : string ) : boolean {
6573 try {
66- const result = spawnSync ( 'ddev' , [ 'exec' , 'echo' , 'test' ] , {
74+ const result = sys . spawnSync ( 'ddev' , [ 'exec' , 'echo' , 'test' ] , {
6775 cwd : workspacePath ,
6876 encoding : 'utf-8'
6977 } ) ;
@@ -197,7 +205,7 @@ export class DdevUtils {
197205 // We use 'env' to set environment variables inside the container
198206 const args = [ 'exec' , 'env' , 'XDEBUG_MODE=off' , ...command ] ;
199207
200- const result = spawnSync ( 'ddev' , args , {
208+ const result = sys . spawnSync ( 'ddev' , args , {
201209 cwd : workspacePath ,
202210 encoding : 'utf-8'
203211 } ) ;
0 commit comments