@@ -19,7 +19,6 @@ export class AsarPackager {
19
19
20
20
constructor (
21
21
private readonly config : {
22
- appDir : string
23
22
defaultDestination : string
24
23
resourcePath : string
25
24
options : AsarOptions
@@ -86,7 +85,14 @@ export class AsarPackager {
86
85
return
87
86
}
88
87
}
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
90
96
copiedFiles . add ( destination )
91
97
92
98
// If transformed data, skip symlink logic
@@ -100,8 +106,7 @@ export class AsarPackager {
100
106
return this . copyFileOrData ( undefined , source , destination , stat )
101
107
}
102
108
103
- const realPathRelative = path . relative ( this . config . appDir , realPathFile )
104
- const symlinkTarget = path . resolve ( this . rootForAppFilesWithoutAsar , realPathRelative )
109
+ const realPathRelative = path . relative ( sourceDir , realPathFile )
105
110
const isOutsidePackage = realPathRelative . startsWith ( ".." )
106
111
if ( isOutsidePackage ) {
107
112
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 {
110
115
)
111
116
}
112
117
118
+ const symlinkTarget = path . resolve ( this . rootForAppFilesWithoutAsar , realPathRelative )
113
119
await this . copyFileOrData ( undefined , source , symlinkTarget , stat )
114
120
const target = path . relative ( path . dirname ( destination ) , symlinkTarget )
115
121
fsNode . symlinkSync ( target , destination )
@@ -130,7 +136,7 @@ export class AsarPackager {
130
136
const dest = path . resolve ( this . rootForAppFilesWithoutAsar , relative )
131
137
132
138
matchUnpacker ( file , dest , metadata )
133
- taskManager . addTask ( writeFileOrSymlink ( transformedData , file , dest , metadata ) )
139
+ taskManager . addTask ( writeFileOrSymlink ( { transformedData, file, destination : dest , stat : metadata , fileSet } ) )
134
140
135
141
if ( taskManager . tasks . length > MAX_FILE_REQUESTS ) {
136
142
await taskManager . awaitTasks ( )
0 commit comments