Skip to content

Commit

Permalink
fix(daffio): use process.cwd for docs path on server
Browse files Browse the repository at this point in the history
  • Loading branch information
damienwebdev committed Jan 19, 2024
1 parent 891a730 commit 57b30fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
8 changes: 2 additions & 6 deletions apps/daffio/src/app/app.server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { DaffioAppComponent } from './app.component';
import { AppModule } from './app.module';
import { DaffioAssetFetchServerService } from './core/assets/fetch/server.service';
import { DaffioAssetFetchService } from './core/assets/fetch/service.interface';
import { DAFFIO_DOCS_PATH_TOKEN } from './docs/services/docs-path.token';
import { environment } from '../environments/environment';
import { provideServerDocsPath } from './docs/services/docs-path-server';

@NgModule({
imports: [
Expand All @@ -15,10 +14,7 @@ import { environment } from '../environments/environment';
],
bootstrap: [DaffioAppComponent],
providers: [
{
provide: DAFFIO_DOCS_PATH_TOKEN,
useValue: environment.docsPath,
},
provideServerDocsPath(),
{
provide: DaffioAssetFetchService,
useExisting: DaffioAssetFetchServerService,
Expand Down
20 changes: 20 additions & 0 deletions apps/daffio/src/app/docs/services/docs-path-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Provider } from '@angular/core';
import { join } from 'path';

import { DAFFIO_DOCS_PATH_TOKEN } from './docs-path.token';
import { environment } from '../../../environments/environment';

/**
* The path on the server to the docs folder.
*/
const daffioDocsPathServerFactory = () => join(process.cwd(), environment.docsPath);

/**
* A provider for the docs path for the server.
*/
export function provideServerDocsPath(): Provider {
return {
provide: DAFFIO_DOCS_PATH_TOKEN,
useFactory: daffioDocsPathServerFactory,
};
};

0 comments on commit 57b30fc

Please sign in to comment.