@@ -84,6 +84,9 @@ import util from "./util.js";
8484 * });
8585 */
8686async function get ( options ) {
87+ if ( fs . existsSync ( options . cacheDir ) === false ) {
88+ await fsm . mkdir ( options . cacheDir , { recursive : true } ) ;
89+ }
8790 await getNwjs ( options ) ;
8891 if ( options . ffmpeg === true ) {
8992 await getFfmpeg ( options ) ;
@@ -123,7 +126,12 @@ const getNwjs = async (options) => {
123126 } ) ;
124127 } else {
125128 fs . createReadStream ( out )
126- . pipe ( unzipper . Extract ( { path : options . cacheDir } ) ) ;
129+ . pipe ( unzipper . Extract ( { path : options . cacheDir } ) )
130+ . on ( "finish" , async ( ) => {
131+ if ( options . platform === "osx" ) {
132+ await createSymlinks ( options ) ;
133+ }
134+ } ) ;
127135 }
128136 return ;
129137 }
@@ -194,7 +202,12 @@ const getNwjs = async (options) => {
194202 } ) ;
195203 } else {
196204 fs . createReadStream ( out )
197- . pipe ( unzipper . Extract ( { path : options . cacheDir } ) ) ;
205+ . pipe ( unzipper . Extract ( { path : options . cacheDir } ) )
206+ . on ( "finish" , async ( ) => {
207+ if ( options . platform === "osx" ) {
208+ await createSymlinks ( options ) ;
209+ }
210+ } ) ;
198211 }
199212}
200213
@@ -346,4 +359,20 @@ const getNodeHeaders = async (options) => {
346359 ) ;
347360}
348361
362+ const createSymlinks = async ( options ) => {
363+ const frameworksPath = path . join ( process . cwd ( ) , options . cacheDir , `nwjs${ options . flavor === "sdk" ? "-sdk" : "" } -v${ options . version } -${ options . platform } -${ options . arch } ` , "nwjs.app" , "Contents" , "Frameworks" , "nwjs Framework.framework" ) ;
364+ const symlinks = [
365+ path . join ( frameworksPath , "Helpers" ) ,
366+ path . join ( frameworksPath , "Libraries" ) ,
367+ path . join ( frameworksPath , "nwjs Framework" ) ,
368+ path . join ( frameworksPath , "Resources" ) ,
369+ path . join ( frameworksPath , "Versions" , "Current" ) ,
370+ ] ;
371+ for await ( const symlink of symlinks ) {
372+ const link = String ( await fsm . readFile ( symlink ) ) ;
373+ await fsm . rm ( symlink ) ;
374+ await fsm . symlink ( link , symlink ) ;
375+ }
376+ } ;
377+
349378export default get ;
0 commit comments