Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nestjs/nest
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Feb 5, 2019
2 parents 7edf598 + bf04704 commit 7c772b2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/common/interfaces/http/http-server.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface HttpServer {
setErrorHandler?(handler: Function);
setNotFoundHandler?(handler: Function);
useStaticAssets?(...args: any[]): this;
setBaseViewsDir?(path: string): this;
setBaseViewsDir?(path: string | string[]): this;
setViewEngine?(engineOrOptions: any): this;
createMiddlewareFactory(
method: RequestMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export interface INestExpressApplication {
useStaticAssets(path: string, options?: ServeStaticOptions): this;

/**
* Sets a base directory for templates (views).
* Sets one or multiple base directories for templates (views).
* Example `app.setBaseViewsDir('views')`
*
* @returns {this}
*/
setBaseViewsDir(path: string): this;
setBaseViewsDir(path: string | string[]): this;

/**
* Sets a view engine for templates (views).
Expand Down
8 changes: 6 additions & 2 deletions packages/common/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ export class Logger implements LoggerService {
this.printMessage(message, clc.yellow, context, isTimeDiffEnabled);
}

protected static isActive(): boolean {
return Logger.contextEnvironment !== NestEnvironment.TEST;
}

private static printMessage(
message: any,
color: (message: string) => string,
context: string = '',
isTimeDiffEnabled?: boolean,
) {
if (Logger.contextEnvironment === NestEnvironment.TEST) {
if (!this.isActive()) {
return;
}
const output = isObject(message) ? JSON.stringify(message, null, 2) : message;
Expand All @@ -108,7 +112,7 @@ export class Logger implements LoggerService {
}

private static printStackTrace(trace: string) {
if (this.contextEnvironment === NestEnvironment.TEST || !trace) {
if (!this.isActive() || !trace) {
return;
}
process.stdout.write(trace);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/adapters/express-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class ExpressAdapter implements HttpServer {
return this.use(express.static(path, options));
}

setBaseViewsDir(path: string) {
setBaseViewsDir(path: string | string[]) {
return this.set('views', path);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/nest-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export class NestApplication extends NestApplicationContext
return this;
}

public setBaseViewsDir(path: string): this {
public setBaseViewsDir(path: string | string[]): this {
this.httpAdapter.setBaseViewsDir && this.httpAdapter.setBaseViewsDir(path);
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/microservices/server/server-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
const nameExtended = this.parseDeepServiceName(name, key);
const deepDefinition = grpcDefinition[key];

const isServiceDefined = !isUndefined(deepDefinition.service);
const isServiceDefined = deepDefinition && !isUndefined(deepDefinition.service);
const isServiceBoolean = isServiceDefined
? deepDefinition.service !== false
: false;
Expand Down

0 comments on commit 7c772b2

Please sign in to comment.