File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,26 @@ switch (processLocation()) {
1616function getPackagesPath ( ) : string {
1717 switch ( processLocation ( ) ) {
1818 case "MAIN" :
19+ // Directory in which kernel.asar is in
1920 const kernelPath = path . join ( __dirname , ".." , ".." , ".." ) ;
20- const packagesPath = path . resolve ( kernelPath , "packages" ) ;
21+ const rootPath = path . parse ( __dirname ) . root ;
22+ let currentPath = kernelPath ;
2123
22- if ( ! fs . existsSync ( packagesPath ) ) {
23- console . log (
24- `No package directory found. Creating one at "${ packagesPath } "`
25- ) ;
24+ while ( true ) {
25+ if ( fs . existsSync ( path . join ( currentPath , "packages" ) ) ) break ;
26+ if ( currentPath !== rootPath ) {
27+ // Traverse further up
28+ currentPath = path . parse ( currentPath ) . dir ;
29+ continue ;
30+ } ;
31+
32+ const packagesPath = path . join ( kernelPath , "packages" ) ;
33+ console . log ( `No package directory found. Creating one at "${ packagesPath } "` ) ;
2634 fs . mkdirSync ( packagesPath ) ;
35+ return packagesPath ;
2736 }
2837
29- return packagesPath ;
38+ return path . join ( currentPath , "packages" ) ;
3039
3140 case "PRELOAD" :
3241 return ipcRenderer . sendSync ( "KERNEL_getPackagesPath" ) ;
You can’t perform that action at this time.
0 commit comments