33const path = require ( 'path' ) ;
44
55const execa = require ( 'execa' ) ;
6- const fs = require ( 'fs-extra' ) ;
6+ const {
7+ promises : {
8+ readFile,
9+ mkdir
10+ }
11+ } = require ( 'fs' ) ;
712const { Listr } = require ( 'listr2' ) ;
813
914const common = require ( './common' ) ;
1015const {
1116 getNodeV8Version,
1217 filterForVersion,
1318 addToGitignore,
14- replaceGitignore
19+ replaceGitignore,
20+ removeDirectory
1521} = require ( './util' ) ;
1622const applyNodeChanges = require ( './applyNodeChanges' ) ;
1723const { chromiumGit, v8Deps } = require ( './constants' ) ;
@@ -76,7 +82,7 @@ function checkoutBranch() {
7682function removeDepsV8 ( ) {
7783 return {
7884 title : 'Remove deps/v8' ,
79- task : ( ctx ) => fs . remove ( path . join ( ctx . nodeDir , 'deps/v8' ) )
85+ task : ( ctx ) => removeDirectory ( path . join ( ctx . nodeDir , 'deps/v8' ) )
8086 } ;
8187}
8288
@@ -93,7 +99,7 @@ function cloneLocalV8() {
9399function removeDepsV8Git ( ) {
94100 return {
95101 title : 'Remove deps/v8/.git' ,
96- task : ( ctx ) => fs . remove ( path . join ( ctx . nodeDir , 'deps/v8/.git' ) )
102+ task : ( ctx ) => removeDirectory ( path . join ( ctx . nodeDir , 'deps/v8/.git' ) )
97103 } ;
98104}
99105
@@ -112,7 +118,7 @@ function updateV8Deps() {
112118 return {
113119 title : 'Update V8 DEPS' ,
114120 task : async ( ctx ) => {
115- const newV8Version = getNodeV8Version ( ctx . nodeDir ) ;
121+ const newV8Version = await getNodeV8Version ( ctx . nodeDir ) ;
116122 const repoPrefix = newV8Version . majorMinor >= 86 ? '' : 'v8/' ;
117123 const deps = filterForVersion ( v8Deps . map ( ( v8Dep ) => ( {
118124 ...v8Dep ,
@@ -139,7 +145,7 @@ function updateV8Deps() {
139145}
140146
141147async function readDeps ( nodeDir , depName ) {
142- const depsStr = await fs . readFile ( path . join ( nodeDir , 'deps/v8/DEPS' ) , 'utf8' ) ;
148+ const depsStr = await readFile ( path . join ( nodeDir , 'deps/v8/DEPS' ) , 'utf8' ) ;
143149 const start = depsStr . indexOf ( 'deps = {' ) ;
144150 const end = depsStr . indexOf ( '\n}' , start ) + 2 ;
145151 const depsDeclaration = depsStr . substring ( start , end ) . replace ( / ^ * # .* / gm, '' ) ;
@@ -154,12 +160,12 @@ async function readDeps(nodeDir, depName) {
154160}
155161
156162async function fetchFromGit ( cwd , repo , commit ) {
157- await fs . ensureDir ( cwd ) ;
163+ await mkdir ( cwd , { recursive : true } ) ;
158164 await exec ( 'init' ) ;
159165 await exec ( 'remote' , 'add' , 'origin' , repo ) ;
160166 await exec ( 'fetch' , 'origin' , commit ) ;
161167 await exec ( 'reset' , '--hard' , 'FETCH_HEAD' ) ;
162- await fs . remove ( path . join ( cwd , '.git' ) ) ;
168+ await removeDirectory ( path . join ( cwd , '.git' ) ) ;
163169
164170 function exec ( ...options ) {
165171 return execa ( 'git' , options , { cwd } ) ;
0 commit comments