11import * as path from 'path' ;
2+ import { sanitizePath } from '@contentstack/cli-utilities' ;
23import { PersonalizationConfig , ExportConfig , ExperienceStruct } from '../types' ;
34import { formatError , fsUtil , log , PersonalizationAdapter } from '../utils' ;
45
@@ -19,9 +20,9 @@ export default class ExportExperiences extends PersonalizationAdapter<ExportConf
1920 this . exportConfig = exportConfig ;
2021 this . personalizationConfig = exportConfig . modules . personalization ;
2122 this . experiencesFolderPath = path . resolve (
22- exportConfig . data ,
23- exportConfig . branchName || '' ,
24- this . personalizationConfig . dirName ,
23+ sanitizePath ( exportConfig . data ) ,
24+ sanitizePath ( exportConfig . branchName || '' ) ,
25+ sanitizePath ( this . personalizationConfig . dirName ) ,
2526 'experiences' ,
2627 ) ;
2728 }
@@ -38,7 +39,7 @@ export default class ExportExperiences extends PersonalizationAdapter<ExportConf
3839 log ( this . exportConfig , 'No Experiences found with the give project' , 'info' ) ;
3940 return ;
4041 }
41- fsUtil . writeFile ( path . resolve ( this . experiencesFolderPath , 'experiences.json' ) , experiences ) ;
42+ fsUtil . writeFile ( path . resolve ( sanitizePath ( this . experiencesFolderPath ) , 'experiences.json' ) , experiences ) ;
4243
4344 const experienceToVariantsStrList : Array < string > = [ ] ;
4445 const experienceToContentTypesMap : Record < string , string [ ] > = { } ;
@@ -62,12 +63,12 @@ export default class ExportExperiences extends PersonalizationAdapter<ExportConf
6263 }
6364 }
6465 fsUtil . writeFile (
65- path . resolve ( this . experiencesFolderPath , 'experiences-variants-ids.json' ) ,
66+ path . resolve ( sanitizePath ( this . experiencesFolderPath ) , 'experiences-variants-ids.json' ) ,
6667 experienceToVariantsStrList ,
6768 ) ;
6869
6970 fsUtil . writeFile (
70- path . resolve ( this . experiencesFolderPath , 'experiences-content-types.json' ) ,
71+ path . resolve ( sanitizePath ( this . experiencesFolderPath ) , 'experiences-content-types.json' ) ,
7172 experienceToContentTypesMap ,
7273 ) ;
7374 log ( this . exportConfig , 'All the experiences have been exported successfully!' , 'success' ) ;
0 commit comments