1
1
import { execSync } from 'child_process' ;
2
- import { lstatSync , readFileSync , writeFileSync } from 'fs' ;
3
2
4
3
function pretest ( ) : void {
5
4
execSync ( `dfx canister uninstall-code management_canister || true` , {
6
5
stdio : 'inherit'
7
6
} ) ;
8
7
9
- // We generate this file without the workaroundForMultipleIDLPathsProblem so that we can do an exact comparison with the azle/canisters/management/idl/index.ts file
10
- execSync (
11
- `npm exec --offline azle generate ../../../../../../src/stable/lib/canisters/management/idl/ic.did > src/idl/management_no_workaround.ts` ,
12
- {
13
- stdio : 'inherit'
14
- }
15
- ) ;
16
-
17
- execSync (
18
- 'npx prettier --ignore-path null --write src/idl/management_no_workaround.ts' ,
19
- {
20
- stdio : 'inherit'
21
- }
22
- ) ;
23
-
24
8
execSync (
25
9
`npm exec --offline azle generate ../../../../../../src/stable/lib/canisters/management/idl/ic.did > src/idl/management.ts` ,
26
10
{
27
11
stdio : 'inherit'
28
12
}
29
13
) ;
30
14
31
- workaroundForMultipleIDLPathsProblem ( ) ;
32
-
33
15
execSync ( 'npx prettier --ignore-path null --write src/idl/management.ts' , {
34
16
stdio : 'inherit'
35
17
} ) ;
@@ -51,27 +33,3 @@ function pretest(): void {
51
33
}
52
34
53
35
pretest ( ) ;
54
-
55
- // TODO remove once this issue is resolved: https://github.com/dfinity/agent-js/issues/977
56
- // Basically what we do here is to replace import { IDL } from '@dfinity/candid' with import { IDL } from 'azle'
57
- // but only when azle is a symlink (accomplished usually in our dev environment through npm link azle)
58
- // The multiple IDL paths problem only occurs at least in the context of this test, in our local symlink
59
- // testing environment. Users shouldn't run into this issue because they will not have symlinked azle
60
- // The GitHub Actions tests on a release will run this test against azle as an npm package
61
- function workaroundForMultipleIDLPathsProblem ( ) : void {
62
- if (
63
- lstatSync ( '../../../../../node_modules/azle' ) . isSymbolicLink ( ) === false
64
- ) {
65
- return ;
66
- }
67
-
68
- const generatedTypesPath = 'src/idl/management.ts' ;
69
-
70
- writeFileSync (
71
- generatedTypesPath ,
72
- readFileSync ( generatedTypesPath , 'utf-8' ) . replace (
73
- / i m p o r t \s * { \s * I D L \s * } \s * f r o m \s * [ ' " ] @ d f i n i t y \/ c a n d i d [ ' " ] / g,
74
- "import { IDL } from 'azle'"
75
- )
76
- ) ;
77
- }
0 commit comments