1313//===----------------------------------------------------------------------===//
1414
1515import * as vscode from "vscode" ;
16- import * as fs from "fs" ;
16+ import * as fs from "fs/promises " ;
1717import * as path from "path" ;
1818import { expect } from "chai" ;
1919import { waitForNoRunningTasks } from "../../utilities" ;
@@ -29,6 +29,7 @@ import {
2929 folderInRootWorkspace ,
3030 updateSettings ,
3131} from "../utilities/testutilities" ;
32+ import { pathExists } from "../../../src/utilities/filesystem" ;
3233
3334suite ( "Build Commands" , function ( ) {
3435 let folderContext : FolderContext ;
@@ -60,8 +61,8 @@ suite("Build Commands", function () {
6061
6162 teardown ( async ( ) => {
6263 // Remove the build directory after each test case
63- if ( fs . existsSync ( buildPath ) ) {
64- fs . rmSync ( buildPath , { recursive : true , force : true } ) ;
64+ if ( await pathExists ( buildPath ) ) {
65+ await fs . rm ( buildPath , { recursive : true , force : true } ) ;
6566 }
6667 } ) ;
6768
@@ -79,12 +80,12 @@ suite("Build Commands", function () {
7980 let result = await vscode . commands . executeCommand ( Commands . RUN ) ;
8081 expect ( result ) . to . be . true ;
8182
82- const beforeItemCount = fs . readdirSync ( buildPath ) . length ;
83+ const beforeItemCount = ( await fs . readdir ( buildPath ) ) . length ;
8384
8485 result = await vscode . commands . executeCommand ( Commands . CLEAN_BUILD ) ;
8586 expect ( result ) . to . be . true ;
8687
87- const afterItemCount = fs . readdirSync ( buildPath ) . length ;
88+ const afterItemCount = ( await fs . readdir ( buildPath ) ) . length ;
8889 // This test will run in order after the Swift: Run Build test,
8990 // where .build folder is going to be filled with built artifacts.
9091 // After executing the clean command the build directory is guranteed to have less entry.
0 commit comments