11import { dir as tmpDir } from "tmp-promise" ;
2- import { writeFile } from "fs/promises" ;
3- import { join } from "path" ;
4- import { execFile } from "child_process" ;
5- import { promisify } from "util" ;
2+ import { writeFile } from "node: fs/promises" ;
3+ import { join } from "node: path" ;
4+ import { execFile } from "node: child_process" ;
5+ import { promisify } from "node: util" ;
66import { dump as yamlDump } from "js-yaml" ;
7- import * as fs from "fs/promises" ;
7+ import * as fs from "node: fs/promises" ;
88
99const execFileAsync = promisify ( execFile ) ;
1010
@@ -13,6 +13,7 @@ export interface TestWorkspace {
1313 cleanup : ( ) => Promise < void > ;
1414 writeJson : ( path : string , content : unknown ) => Promise < void > ;
1515 writeYarnrc : ( content : unknown ) => Promise < void > ;
16+ writeCatalogsYml : ( content : unknown ) => Promise < void > ;
1617 yarn : {
1718 ( args : string [ ] ) : Promise < { stdout : string ; stderr : string } > ;
1819 install ( ) : Promise < { stdout : string ; stderr : string } > ;
@@ -58,14 +59,20 @@ export async function createTestWorkspace(): Promise<TestWorkspace> {
5859 const existingContent = await fs
5960 . readFile ( yarnrcPath , "utf8" )
6061 . catch ( ( ) => "" ) ;
61- await writeFile ( yarnrcPath , existingContent + "\n" + yamlDump ( content ) ) ;
62+ await writeFile ( yarnrcPath , `${ existingContent } \n${ yamlDump ( content ) } ` ) ;
63+ } ;
64+
65+ const writeCatalogsYml = async ( content : unknown ) => {
66+ const catalogsYmlPath = join ( path , "catalogs.yml" ) ;
67+ await writeFile ( catalogsYmlPath , yamlDump ( content ) ) ;
6268 } ;
6369
6470 return {
6571 path,
6672 cleanup,
6773 writeJson,
6874 writeYarnrc : writeYaml ,
75+ writeCatalogsYml,
6976 yarn,
7077 } ;
7178}
@@ -98,7 +105,7 @@ module.exports = {
98105 // Create a new descriptor with the resolved version
99106 return structUtils.makeDescriptor(
100107 structUtils.makeIdent(dependency.scope, dependency.name),
101- \` npm:\$\{ version\}\`
108+ ' npm:' + version
102109 );
103110 }
104111 }
@@ -124,7 +131,10 @@ export function extractDependencies(log: string): string[] {
124131 ( depsString ) =>
125132 JSON . parse ( depsString ) as { value : string ; children : object } ,
126133 )
127- . reduce ( ( result , item ) => [ ...result , item . value ] , [ ] as string [ ] ) ;
134+ . reduce ( ( result , item ) => {
135+ result . push ( item . value ) ;
136+ return result ;
137+ } , [ ] as string [ ] ) ;
128138}
129139
130140export async function hasDependency (
0 commit comments