@@ -5,7 +5,8 @@ const childProcess = require('child_process')
5
5
const { fork, spawn } = childProcess
6
6
const exec = promisify ( childProcess . exec )
7
7
const http = require ( 'http' )
8
- const fs = require ( 'fs' )
8
+ const { existsSync, readFileSync, unlinkSync } = require ( 'fs' )
9
+ const fs = require ( 'fs/promises' )
9
10
const { builtinModules } = require ( 'module' )
10
11
const os = require ( 'os' )
11
12
const path = require ( 'path' )
@@ -218,7 +219,7 @@ async function createSandbox (dependencies = [], isGitRepo = false,
218
219
const out = path . join ( folder , `dd-trace-${ version } .tgz` )
219
220
const allDependencies = [ `file:${ out } ` ] . concat ( cappedDependencies )
220
221
221
- fs . mkdirSync ( folder )
222
+ await fs . mkdir ( folder )
222
223
const preferOfflineFlag = process . env . OFFLINE === '1' || process . env . OFFLINE === 'true' ? ' --prefer-offline' : ''
223
224
const addCommand = `yarn add ${ allDependencies . join ( ' ' ) } --ignore-engines${ preferOfflineFlag } `
224
225
const addOptions = { cwd : folder , env : restOfEnv }
@@ -250,14 +251,14 @@ async function createSandbox (dependencies = [], isGitRepo = false,
250
251
251
252
if ( isGitRepo ) {
252
253
await exec ( 'git init' , { cwd : folder } )
253
- fs . writeFileSync ( path . join ( folder , '.gitignore' ) , 'node_modules/' , { flush : true } )
254
+ await fs . writeFile ( path . join ( folder , '.gitignore' ) , 'node_modules/' , { flush : true } )
254
255
await exec ( 'git config user.email "[email protected] "' , { cwd :
folder } )
255
256
await exec ( 'git config user.name "John Doe"' , { cwd : folder } )
256
257
await exec ( 'git config commit.gpgsign false' , { cwd : folder } )
257
258
258
259
// Create a unique local bare repo for this test
259
260
const localRemotePath = path . join ( folder , '..' , `${ path . basename ( folder ) } -remote.git` )
260
- if ( ! fs . existsSync ( localRemotePath ) ) {
261
+ if ( ! existsSync ( localRemotePath ) ) {
261
262
await exec ( `git init --bare ${ localRemotePath } ` )
262
263
}
263
264
@@ -333,7 +334,7 @@ function telemetryForwarder (shouldExpectTelemetryPoints = true) {
333
334
const cleanup = function ( ) {
334
335
let msgs
335
336
try {
336
- msgs = fs . readFileSync ( process . env . FORWARDER_OUT , 'utf8' ) . trim ( ) . split ( '\n' )
337
+ msgs = readFileSync ( process . env . FORWARDER_OUT , 'utf8' ) . trim ( ) . split ( '\n' )
337
338
} catch ( e ) {
338
339
if ( shouldExpectTelemetryPoints && e . code === 'ENOENT' && retries < 10 ) {
339
340
return tryAgain ( )
@@ -356,7 +357,7 @@ function telemetryForwarder (shouldExpectTelemetryPoints = true) {
356
357
}
357
358
msgs [ i ] = [ telemetryType , parsed ]
358
359
}
359
- fs . unlinkSync ( process . env . FORWARDER_OUT )
360
+ unlinkSync ( process . env . FORWARDER_OUT )
360
361
delete process . env . FORWARDER_OUT
361
362
delete process . env . DD_TELEMETRY_FORWARDER_PATH
362
363
return msgs
0 commit comments