Skip to content

Commit

Permalink
Merge pull request #20 from ioj4/master
Browse files Browse the repository at this point in the history
fix packages path search
  • Loading branch information
Kyza authored Aug 13, 2024
2 parents 900e53a + bb0d6ea commit a9cf8d9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/core/packageLoader/getPackagesPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@ switch (processLocation()) {
function getPackagesPath(): string {
switch (processLocation()) {
case "MAIN":
// Directory in which kernel.asar is in
const kernelPath = path.join(__dirname, "..", "..", "..");
const packagesPath = path.resolve(kernelPath, "packages");
const rootPath = path.parse(__dirname).root;
let currentPath = kernelPath;

if (!fs.existsSync(packagesPath)) {
console.log(
`No package directory found. Creating one at "${packagesPath}"`
);
while (true) {
if (fs.existsSync(path.join(currentPath, "packages"))) break;
if (currentPath !== rootPath) {
// Traverse further up
currentPath = path.parse(currentPath).dir;
continue;
};

const packagesPath = path.join(kernelPath, "packages");
console.log(`No package directory found. Creating one at "${packagesPath}"`);
fs.mkdirSync(packagesPath);
return packagesPath;
}

return packagesPath;
return path.join(currentPath, "packages");

case "PRELOAD":
return ipcRenderer.sendSync("KERNEL_getPackagesPath");
Expand Down

0 comments on commit a9cf8d9

Please sign in to comment.