@@ -19,7 +19,6 @@ export class AsarPackager {
1919
2020 constructor (
2121 private readonly config : {
22- appDir : string
2322 defaultDestination : string
2423 resourcePath : string
2524 options : AsarOptions
@@ -86,7 +85,14 @@ export class AsarPackager {
8685 return
8786 }
8887 }
89- const writeFileOrSymlink = async ( transformedData : string | Buffer | undefined , source : string , destination : string , stat : fs . Stats ) => {
88+ const writeFileOrSymlink = async ( options : { transformedData : string | Buffer | undefined ; file : string ; destination : string ; stat : fs . Stats ; fileSet : ResolvedFileSet } ) => {
89+ const {
90+ transformedData,
91+ file : source ,
92+ destination,
93+ stat,
94+ fileSet : { src : sourceDir } ,
95+ } = options
9096 copiedFiles . add ( destination )
9197
9298 // If transformed data, skip symlink logic
@@ -100,8 +106,7 @@ export class AsarPackager {
100106 return this . copyFileOrData ( undefined , source , destination , stat )
101107 }
102108
103- const realPathRelative = path . relative ( this . config . appDir , realPathFile )
104- const symlinkTarget = path . resolve ( this . rootForAppFilesWithoutAsar , realPathRelative )
109+ const realPathRelative = path . relative ( sourceDir , realPathFile )
105110 const isOutsidePackage = realPathRelative . startsWith ( ".." )
106111 if ( isOutsidePackage ) {
107112 log . error ( { source : log . filePath ( source ) , realPathFile : log . filePath ( realPathFile ) } , `unable to copy, file is symlinked outside the package` )
@@ -110,6 +115,7 @@ export class AsarPackager {
110115 )
111116 }
112117
118+ const symlinkTarget = path . resolve ( this . rootForAppFilesWithoutAsar , realPathRelative )
113119 await this . copyFileOrData ( undefined , source , symlinkTarget , stat )
114120 const target = path . relative ( path . dirname ( destination ) , symlinkTarget )
115121 fsNode . symlinkSync ( target , destination )
@@ -130,7 +136,7 @@ export class AsarPackager {
130136 const dest = path . resolve ( this . rootForAppFilesWithoutAsar , relative )
131137
132138 matchUnpacker ( file , dest , metadata )
133- taskManager . addTask ( writeFileOrSymlink ( transformedData , file , dest , metadata ) )
139+ taskManager . addTask ( writeFileOrSymlink ( { transformedData, file, destination : dest , stat : metadata , fileSet } ) )
134140
135141 if ( taskManager . tasks . length > MAX_FILE_REQUESTS ) {
136142 await taskManager . awaitTasks ( )
0 commit comments