Add mechanism for NPM package auto-discovery
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-07-02 21:45:15 -05:00
parent 5d960e6186
commit b3b5b169e8
6 changed files with 204 additions and 0 deletions

View File

@@ -48,6 +48,12 @@ export function appPath(...parts: PathLike[]): UniversalPath {
* The main application container.
*/
export class Application extends Container {
public static readonly NODE_MODULES_INJECTION = 'extollo/npm'
public static get NODE_MODULES_PROVIDER(): string {
return process.env.EXTOLLO_NPM || 'pnpm'
}
public static getContainer(): Container {
const existing = <Container | undefined> globalRegistry.getGlobal('extollo/injector')
if ( !existing ) {
@@ -205,6 +211,7 @@ export class Application extends Container {
this.setupLogging()
this.registerFactory(new CacheFactory()) // FIXME move this somewhere else?
this.registerSingleton(Application.NODE_MODULES_INJECTION, Application.NODE_MODULES_PROVIDER)
this.make<Logging>(Logging).debug(`Application root: ${this.baseDir}`)
}