1111 */
1212
1313import { logging } from '@angular-devkit/core' ;
14- import * as fse from 'fs-extra ' ;
14+ import * as fs from 'fs/promises ' ;
1515import * as os from 'os' ;
1616import * as path from 'path' ;
1717
1818import * as engine from './engine' ;
1919import { cleanupMonkeypatch } from './engine.prepare-options-helpers' ;
20+ import { pathExists } from '../utils' ;
2021
2122describe ( 'engine - real filesystem tests' , ( ) => {
2223 const logger = new logging . Logger ( 'test' ) ;
@@ -31,16 +32,16 @@ describe('engine - real filesystem tests', () => {
3132 const tmpBase = os . tmpdir ( ) ;
3233 const uniqueDir = `angular-cli-ghpages-test-${ Date . now ( ) } -${ Math . random ( ) . toString ( 36 ) . substring ( 7 ) } ` ;
3334 testDir = path . join ( tmpBase , uniqueDir ) ;
34- await fse . ensureDir ( testDir ) ;
35+ await fs . mkdir ( testDir , { recursive : true } ) ;
3536
3637 // Spy on logger to capture warnings
3738 loggerInfoSpy = jest . spyOn ( logger , 'info' ) ;
3839 } ) ;
3940
4041 afterEach ( async ( ) => {
4142 // Clean up temp directory after each test
42- if ( await fse . pathExists ( testDir ) ) {
43- await fse . remove ( testDir ) ;
43+ if ( await pathExists ( testDir ) ) {
44+ await fs . rm ( testDir , { recursive : true } ) ;
4445 }
4546 loggerInfoSpy . mockRestore ( ) ;
4647 } ) ;
@@ -55,7 +56,7 @@ describe('engine - real filesystem tests', () => {
5556 // First create an index.html file
5657 const indexPath = path . join ( testDir , 'index.html' ) ;
5758 const indexContent = '<!DOCTYPE html><html><head><title>Test</title></head><body><h1>Test App</h1></body></html>' ;
58- await fse . writeFile ( indexPath , indexContent ) ;
59+ await fs . writeFile ( indexPath , indexContent ) ;
5960
6061 const ghpages = require ( 'gh-pages' ) ;
6162 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
@@ -70,16 +71,16 @@ describe('engine - real filesystem tests', () => {
7071 await engine . run ( testDir , options , logger ) ;
7172
7273 const notFoundPath = path . join ( testDir , '404.html' ) ;
73- const exists = await fse . pathExists ( notFoundPath ) ;
74+ const exists = await pathExists ( notFoundPath ) ;
7475 expect ( exists ) . toBe ( true ) ;
7576
76- const notFoundContent = await fse . readFile ( notFoundPath , 'utf-8' ) ;
77+ const notFoundContent = await fs . readFile ( notFoundPath , 'utf-8' ) ;
7778 expect ( notFoundContent ) . toBe ( indexContent ) ;
7879 } ) ;
7980
8081 it ( 'should NOT create 404.html when notfound is false' , async ( ) => {
8182 const indexPath = path . join ( testDir , 'index.html' ) ;
82- await fse . writeFile ( indexPath , '<html><body>Test</body></html>' ) ;
83+ await fs . writeFile ( indexPath , '<html><body>Test</body></html>' ) ;
8384
8485 const ghpages = require ( 'gh-pages' ) ;
8586 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
@@ -94,7 +95,7 @@ describe('engine - real filesystem tests', () => {
9495 await engine . run ( testDir , options , logger ) ;
9596
9697 const notFoundPath = path . join ( testDir , '404.html' ) ;
97- const exists = await fse . pathExists ( notFoundPath ) ;
98+ const exists = await pathExists ( notFoundPath ) ;
9899 expect ( exists ) . toBe ( false ) ;
99100 } ) ;
100101
@@ -122,13 +123,13 @@ describe('engine - real filesystem tests', () => {
122123 ) ;
123124
124125 const notFoundPath = path . join ( testDir , '404.html' ) ;
125- const exists = await fse . pathExists ( notFoundPath ) ;
126+ const exists = await pathExists ( notFoundPath ) ;
126127 expect ( exists ) . toBe ( false ) ;
127128 } ) ;
128129
129130 it ( 'should NOT create 404.html when dry-run is true' , async ( ) => {
130131 const indexPath = path . join ( testDir , 'index.html' ) ;
131- await fse . writeFile ( indexPath , '<html><body>Test</body></html>' ) ;
132+ await fs . writeFile ( indexPath , '<html><body>Test</body></html>' ) ;
132133
133134 const ghpages = require ( 'gh-pages' ) ;
134135 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
@@ -143,7 +144,7 @@ describe('engine - real filesystem tests', () => {
143144 await engine . run ( testDir , options , logger ) ;
144145
145146 const notFoundPath = path . join ( testDir , '404.html' ) ;
146- const exists = await fse . pathExists ( notFoundPath ) ;
147+ const exists = await pathExists ( notFoundPath ) ;
147148 expect ( exists ) . toBe ( false ) ;
148149 } ) ;
149150 } ) ;
@@ -165,7 +166,7 @@ describe('engine - real filesystem tests', () => {
165166 describe ( 'gh-pages v6 delegation - cname and nojekyll' , ( ) => {
166167 it ( 'should pass cname option to gh-pages when provided' , async ( ) => {
167168 const indexPath = path . join ( testDir , 'index.html' ) ;
168- await fse . writeFile ( indexPath , '<html>test</html>' ) ;
169+ await fs . writeFile ( indexPath , '<html>test</html>' ) ;
169170
170171 const ghpages = require ( 'gh-pages' ) ;
171172 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
@@ -194,7 +195,7 @@ describe('engine - real filesystem tests', () => {
194195
195196 it ( 'should pass nojekyll option to gh-pages when enabled' , async ( ) => {
196197 const indexPath = path . join ( testDir , 'index.html' ) ;
197- await fse . writeFile ( indexPath , '<html>test</html>' ) ;
198+ await fs . writeFile ( indexPath , '<html>test</html>' ) ;
198199
199200 const ghpages = require ( 'gh-pages' ) ;
200201 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
@@ -221,7 +222,7 @@ describe('engine - real filesystem tests', () => {
221222
222223 it ( 'should pass both cname and nojekyll options when both enabled' , async ( ) => {
223224 const indexPath = path . join ( testDir , 'index.html' ) ;
224- await fse . writeFile ( indexPath , '<html>test</html>' ) ;
225+ await fs . writeFile ( indexPath , '<html>test</html>' ) ;
225226
226227 const ghpages = require ( 'gh-pages' ) ;
227228 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
@@ -250,12 +251,12 @@ describe('engine - real filesystem tests', () => {
250251
251252 // Verify 404.html is still created by us (not delegated to gh-pages)
252253 const notFoundPath = path . join ( testDir , '404.html' ) ;
253- expect ( await fse . pathExists ( notFoundPath ) ) . toBe ( true ) ;
254+ expect ( await pathExists ( notFoundPath ) ) . toBe ( true ) ;
254255 } ) ;
255256
256257 it ( 'should NOT pass cname when not provided (undefined)' , async ( ) => {
257258 const indexPath = path . join ( testDir , 'index.html' ) ;
258- await fse . writeFile ( indexPath , '<html>test</html>' ) ;
259+ await fs . writeFile ( indexPath , '<html>test</html>' ) ;
259260
260261 const ghpages = require ( 'gh-pages' ) ;
261262 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
@@ -283,7 +284,7 @@ describe('engine - real filesystem tests', () => {
283284
284285 it ( 'should pass nojekyll: false when disabled' , async ( ) => {
285286 const indexPath = path . join ( testDir , 'index.html' ) ;
286- await fse . writeFile ( indexPath , '<html>test</html>' ) ;
287+ await fs . writeFile ( indexPath , '<html>test</html>' ) ;
287288
288289 const ghpages = require ( 'gh-pages' ) ;
289290 jest . spyOn ( ghpages , 'clean' ) . mockImplementation ( ( ) => { } ) ;
0 commit comments