@@ -2,6 +2,7 @@ import {outputContent, outputToken, outputDebug} from './output.js'
22import { joinPath , normalizePath } from './path.js'
33import { OverloadParameters } from '../../private/common/ts/overloaded-parameters.js'
44import { getRandomName , RandomNameFamily } from '../common/string.js'
5+ import { systemTempDir } from '../../private/node/temp-dir.js'
56import {
67 copy as fsCopy ,
78 ensureFile as fsEnsureFile ,
@@ -13,7 +14,6 @@ import {
1314 // @ts -ignore
1415} from 'fs-extra/esm'
1516
16- import { temporaryDirectory , temporaryDirectoryTask } from 'tempy'
1717import { sep , join } from 'pathe'
1818import { findUp as internalFindUp , findUpSync as internalFindUpSync } from 'find-up'
1919import { minimatch } from 'minimatch'
@@ -29,6 +29,7 @@ import {
2929 constants as fsConstants ,
3030 existsSync as fsFileExistsSync ,
3131 unlinkSync as fsUnlinkSync ,
32+ mkdtempSync as fsMkdtempSync ,
3233 accessSync ,
3334 ReadStream ,
3435 WriteStream ,
@@ -75,15 +76,20 @@ export function stripUpPath(path: string, strip: number): string {
7576 * @param callback - The callback that receives the temporary directory.
7677 */
7778export async function inTemporaryDirectory < T > ( callback : ( tmpDir : string ) => T | Promise < T > ) : Promise < T > {
78- return temporaryDirectoryTask ( callback )
79+ const tmpDir = await fsMkdtemp ( join ( systemTempDir , 'tmp-' ) )
80+ try {
81+ return await callback ( tmpDir )
82+ } finally {
83+ await fsRm ( tmpDir , { recursive : true , force : true , maxRetries : 2 } )
84+ }
7985}
8086
8187/**
8288 * Return a temporary directory
8389 * @returns - The path to the temporary directory.
8490 */
8591export function tempDirectory ( ) : string {
86- return temporaryDirectory ( )
92+ return fsMkdtempSync ( join ( systemTempDir , 'tmp-' ) )
8793}
8894
8995/**
0 commit comments