File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
packages/fx-core/src/component/deps-checker Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ export class TestToolChecker implements DepsChecker {
97
97
) ;
98
98
this . telemetryProperties [ TelemetryProperties . SelectedPortableTestToolVersion ] = version ;
99
99
if ( symlinkDir ) {
100
- await createSymlink ( portablePath , symlinkDir ) ;
100
+ await createSymlink ( portablePath , symlinkDir , true ) ;
101
101
return await this . getSuccessDepsInfo ( version , symlinkDir ) ;
102
102
} else {
103
103
return await this . getSuccessDepsInfo ( version , portablePath ) ;
@@ -200,7 +200,7 @@ export class TestToolChecker implements DepsChecker {
200
200
await rename ( tmpPath , portablePath ) ;
201
201
202
202
if ( symlinkDir ) {
203
- await createSymlink ( portablePath , symlinkDir ) ;
203
+ await createSymlink ( portablePath , symlinkDir , true ) ;
204
204
}
205
205
206
206
await this . writeInstallInfoFile ( projectPath ) ;
Original file line number Diff line number Diff line change @@ -14,9 +14,6 @@ export async function unlinkSymlink(linkFilePath: string): Promise<void> {
14
14
const stat = await fs . lstat ( linkFilePath ) ;
15
15
if ( stat . isSymbolicLink ( ) ) {
16
16
await fs . unlink ( linkFilePath ) ;
17
- } else {
18
- // For regular file or directory, remove it
19
- await fs . remove ( linkFilePath ) ;
20
17
}
21
18
} catch ( error : unknown ) {
22
19
const statError = error as { code ?: string } ;
@@ -26,11 +23,23 @@ export async function unlinkSymlink(linkFilePath: string): Promise<void> {
26
23
}
27
24
}
28
25
29
- export async function createSymlink ( target : string , linkFilePath : string ) : Promise < void > {
26
+ export async function createSymlink (
27
+ target : string ,
28
+ linkFilePath : string ,
29
+ forceUpdate = false
30
+ ) : Promise < void > {
30
31
await unlinkSymlink ( linkFilePath ) ;
31
32
// check if destination already exists
32
33
if ( await fs . pathExists ( linkFilePath ) ) {
33
- throw new DepsCheckerError ( Messages . symlinkDirAlreadyExist ( linkFilePath ) , v3DefaultHelpLink ) ;
34
+ if ( ! forceUpdate ) {
35
+ throw new DepsCheckerError ( Messages . symlinkDirAlreadyExist ( linkFilePath ) , v3DefaultHelpLink ) ;
36
+ }
37
+ try {
38
+ // For regular file or directory, unlink will fail so we remove it
39
+ await fs . remove ( linkFilePath ) ;
40
+ } catch {
41
+ throw new DepsCheckerError ( Messages . symlinkDirAlreadyExist ( linkFilePath ) , v3DefaultHelpLink ) ;
42
+ }
34
43
}
35
44
36
45
return await fs . ensureSymlink (
You can’t perform that action at this time.
0 commit comments