@@ -90,19 +90,35 @@ const replacements = [
90
90
] ;
91
91
92
92
function patch ( options ) {
93
+ const { verbose } = options ;
93
94
const binary = findBinary ( options ) ;
94
95
if ( ! fs . existsSync ( binary ) ) {
95
96
throw new Error ( `Binary not found: ${ binary } ` ) ;
96
97
}
98
+ if ( verbose ) {
99
+ console . log ( `Found binary: ${ binary } ` ) ;
100
+ }
97
101
let data = fs . readFileSync ( binary , 'latin1' ) ;
102
+ if ( verbose ) {
103
+ console . log ( `Read: ${ data . length } bytes` ) ;
104
+ }
98
105
if ( data . includes ( PatchedSentinel ) ) {
106
+ if ( verbose ) {
107
+ console . log ( `Already patched` ) ;
108
+ }
99
109
return ;
100
110
}
101
111
const [ , electronVersion ] = data . match ( / E l e c t r o n \/ ( \d + \. \d + \. \d + ) / ) ;
112
+ if ( verbose ) {
113
+ console . log ( `Found version: ${ electronVersion } ` ) ;
114
+ }
102
115
if ( electronVersion . split ( '.' ) [ 0 ] < 12 ) {
103
116
throw new Error ( `Minimal supported Electron version is 12, found ${ electronVersion } ` ) ;
104
117
}
105
118
data = setFuseWireStatus ( data , FuseConst . RunAsNode , false ) ;
119
+ if ( verbose ) {
120
+ console . log ( `Fuse wire status set` ) ;
121
+ }
106
122
for ( const replacement of replacements ) {
107
123
let replaced = false ;
108
124
data = data . replace ( replacement . search , ( match ) => {
@@ -121,8 +137,17 @@ function patch(options) {
121
137
if ( ! replaced ) {
122
138
throw new Error ( `Not found: ${ replacement . name } ` ) ;
123
139
}
140
+ if ( verbose ) {
141
+ console . log ( `Replaced: ${ replacement . name } ` ) ;
142
+ }
143
+ }
144
+ if ( verbose ) {
145
+ console . log ( `Writing output file...` ) ;
124
146
}
125
147
fs . writeFileSync ( binary , Buffer . from ( data , 'latin1' ) ) ;
148
+ if ( verbose ) {
149
+ console . log ( `Done` ) ;
150
+ }
126
151
}
127
152
128
153
function findBinary ( options ) {
0 commit comments