File tree 1 file changed +17
-9
lines changed
1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -168,21 +168,29 @@ function main() {
168
168
*/
169
169
function getNativeBinary ( ) {
170
170
let nativeBinary ;
171
-
172
- if ( os . platform ( ) === 'win32' ) {
171
+ const platform = os . platform ( ) ;
172
+ const arch = os . arch ( ) ;
173
+ if ( platform === 'win32' ) {
173
174
nativeBinary = `${ __dirname } /bin/win32/clang-format.exe` ;
174
175
} else {
175
- nativeBinary = `${ __dirname } /bin/${ os . platform ( ) } _${ os . arch ( ) } /clang-format` ;
176
+ nativeBinary = `${ __dirname } /bin/${ platform } _${ arch } /clang-format` ;
176
177
}
177
178
178
- if ( ! fs . existsSync ( nativeBinary ) ) {
179
- const message = 'This module doesn\'t bundle the clang-format executable for your platform. ' +
180
- `(${ os . platform ( ) } _${ os . arch ( ) } )\n` +
181
- 'Consider installing it with your native package manager instead.\n' ;
182
- throw new Error ( message ) ;
179
+ if ( fs . existsSync ( nativeBinary ) ) {
180
+ return nativeBinary ;
183
181
}
184
182
185
- return nativeBinary ;
183
+ // Let arm64 macOS fall back to x64
184
+ if ( platform === 'darwin' && arch === 'arm64' ) {
185
+ nativeBinary = `${ __dirname } /bin/darwin_x64/clang-format` ;
186
+ if ( fs . existsSync ( nativeBinary ) ) {
187
+ return nativeBinary ;
188
+ }
189
+ }
190
+ const message = 'This module doesn\'t bundle the clang-format executable for your platform. ' +
191
+ `(${ platform } _${ arch } )\n` +
192
+ 'Consider installing it with your native package manager instead.\n' ;
193
+ throw new Error ( message ) ;
186
194
}
187
195
188
196
/**
You can’t perform that action at this time.
0 commit comments