I have some packages inside a folder (named Packs) that is in the same file level of some executed package.
executedPack.m
Packs/subPack01.m
Packs/subPack02.m
Packs/subPack03.m
Today I use this structure do load the sub packages inside the executedPack.m:
(*Execution without Front-End*)
Needs["MyPack`",FileNameJoin[{DirectoryName@$InputFileName,"Packs","subPack01.m"}]]
(*Execution with Front-End*)
Needs["MyPack`",FileNameJoin[{NotebookDirectory[],"Packs","subPack01.m"}]]
The first I use when running the package without front-end, and the last when I evaluate in the front-end.
There is some simpler way to do that, more symmetric? I read some kernel folder structure, but I didn't find more details on that.
Update
Now what I want, but better. This works both in Fron-End and no Front-End execution.
Quiet[Check[SetDirectory@DirectoryName@$InputFileName,SetDirectory@NotebookDirectory[]],SetDirectory::fstr];
Needs["Packs`subPack01`"];