1
1
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
2
// See LICENSE in the project root for license information.
3
3
4
- import * as path from 'path' ;
5
4
import { FileSystem } from '@rushstack/node-core-library' ;
6
5
7
6
import { LastInstallFlag } from '../LastInstallFlag' ;
8
7
9
- const TEMP_DIR : string = path . join ( __dirname , ' temp' ) ;
8
+ const TEMP_DIR_PATH : string = ` ${ __dirname } / temp` ;
10
9
11
10
describe ( LastInstallFlag . name , ( ) => {
12
11
beforeEach ( ( ) => {
13
- FileSystem . ensureEmptyFolder ( TEMP_DIR ) ;
12
+ FileSystem . ensureEmptyFolder ( TEMP_DIR_PATH ) ;
14
13
} ) ;
15
14
16
15
afterEach ( ( ) => {
17
- FileSystem . ensureEmptyFolder ( TEMP_DIR ) ;
16
+ FileSystem . ensureEmptyFolder ( TEMP_DIR_PATH ) ;
18
17
} ) ;
19
18
20
19
it ( 'can create and remove a flag in an empty directory' , ( ) => {
21
20
// preparation
22
- const flag : LastInstallFlag = new LastInstallFlag ( TEMP_DIR ) ;
21
+ const flag : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH ) ;
23
22
FileSystem . deleteFile ( flag . path ) ;
24
23
25
24
// test state, should be invalid since the file doesn't exist
@@ -38,8 +37,8 @@ describe(LastInstallFlag.name, () => {
38
37
39
38
it ( 'can detect if the last flag was in a different state' , ( ) => {
40
39
// preparation
41
- const flag1 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR , { node : '5.0.0' } ) ;
42
- const flag2 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR , { node : '8.9.4' } ) ;
40
+ const flag1 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH , { node : '5.0.0' } ) ;
41
+ const flag2 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH , { node : '8.9.4' } ) ;
43
42
FileSystem . deleteFile ( flag1 . path ) ;
44
43
45
44
// test state, should be invalid since the file doesn't exist
@@ -63,7 +62,7 @@ describe(LastInstallFlag.name, () => {
63
62
64
63
it ( 'can detect if the last flag was in a corrupted state' , ( ) => {
65
64
// preparation, write non-json into flag file
66
- const flag : LastInstallFlag = new LastInstallFlag ( TEMP_DIR ) ;
65
+ const flag : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH ) ;
67
66
FileSystem . writeFile ( flag . path , 'sdfjkaklfjksldajgfkld' ) ;
68
67
69
68
// test state, should be invalid since the file is not JSON
@@ -72,13 +71,13 @@ describe(LastInstallFlag.name, () => {
72
71
} ) ;
73
72
74
73
it ( "throws an error if new storePath doesn't match the old one" , ( ) => {
75
- const flag1 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR , {
74
+ const flag1 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH , {
76
75
packageManager : 'pnpm' ,
77
- storePath : path . join ( TEMP_DIR , ' pnpm-store' )
76
+ storePath : ` ${ TEMP_DIR_PATH } / pnpm-store`
78
77
} ) ;
79
- const flag2 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR , {
78
+ const flag2 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH , {
80
79
packageManager : 'pnpm' ,
81
- storePath : path . join ( TEMP_DIR , ' temp-store' )
80
+ storePath : ` ${ TEMP_DIR_PATH } / temp-store`
82
81
} ) ;
83
82
84
83
flag1 . create ( ) ;
@@ -88,11 +87,11 @@ describe(LastInstallFlag.name, () => {
88
87
} ) ;
89
88
90
89
it ( "doesn't throw an error if conditions for error aren't met" , ( ) => {
91
- const flag1 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR , {
90
+ const flag1 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH , {
92
91
packageManager : 'pnpm' ,
93
- storePath : path . join ( TEMP_DIR , ' pnpm-store' )
92
+ storePath : ` ${ TEMP_DIR_PATH } / pnpm-store`
94
93
} ) ;
95
- const flag2 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR , {
94
+ const flag2 : LastInstallFlag = new LastInstallFlag ( TEMP_DIR_PATH , {
96
95
packageManager : 'npm'
97
96
} ) ;
98
97
0 commit comments