1
1
import fs from 'node:fs' ;
2
- import { extname , join } from 'node:path' ;
2
+ import { extname , join , normalize } from 'node:path' ;
3
3
import type { FsUpdates , UpdateAppOptions } from '../types' ;
4
4
import { getPackageManager } from '../utils/utils' ;
5
5
@@ -22,12 +22,18 @@ export async function mergeIntegrationDir(
22
22
const s = await fs . promises . stat ( srcChildPath ) ;
23
23
24
24
if ( s . isDirectory ( ) ) {
25
- await mergeIntegrationDir ( fileUpdates , opts , srcChildPath , destRootPath , alwaysInRoot ) ;
25
+ await mergeIntegrationDir (
26
+ fileUpdates ,
27
+ opts ,
28
+ srcChildPath ,
29
+ normalize ( destRootPath ) . replace ( / \\ / g, '/' ) ,
30
+ alwaysInRoot
31
+ ) ;
26
32
} else if ( s . isFile ( ) ) {
27
33
const finalDestPath = getFinalDestPath ( opts , destRootPath , destDir , destName , alwaysInRoot ) ;
28
34
29
35
if ( destName === 'package.json' ) {
30
- await mergePackageJsons ( fileUpdates , srcChildPath , destRootPath ) ;
36
+ await mergePackageJsons ( fileUpdates , srcChildPath , destRootPath . replace ( / \\ / g , '/' ) ) ;
31
37
} else if ( destName === 'settings.json' ) {
32
38
await mergeJsons ( fileUpdates , srcChildPath , finalDestPath ) ;
33
39
} else if ( destName === 'README.md' ) {
@@ -37,7 +43,7 @@ export async function mergeIntegrationDir(
37
43
destName === '.prettierignore' ||
38
44
destName === '.eslintignore'
39
45
) {
40
- await mergeIgnoresFile ( fileUpdates , srcChildPath , destRootPath ) ;
46
+ await mergeIgnoresFile ( fileUpdates , srcChildPath , destRootPath . replace ( / \\ / g , '/' ) ) ;
41
47
} else if ( ext === '.css' ) {
42
48
await mergeCss ( fileUpdates , srcChildPath , finalDestPath , opts ) ;
43
49
} else if ( fs . existsSync ( finalDestPath ) ) {
@@ -79,7 +85,8 @@ function getFinalDestPath(
79
85
? destRootPath
80
86
: destChildPath ;
81
87
82
- return finalDestPath ;
88
+ // Normalize path separators to forward slashes for cross-platform compatibility
89
+ return normalize ( finalDestPath ) . replace ( / \\ / g, '/' ) ;
83
90
}
84
91
85
92
async function mergePackageJsons ( fileUpdates : FsUpdates , srcPath : string , destPath : string ) {
0 commit comments