diff --git a/src/index.ts b/src/index.ts index d1fd709d..8e4aa893 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,6 +65,7 @@ export type DockerComposeConfigVolumesResult = { export interface IDockerComposeLogOptions extends IDockerComposeOptions { follow?: boolean + timestamps?: boolean } export interface IDockerComposeBuildOptions extends IDockerComposeOptions { @@ -675,10 +676,13 @@ export const logs = function ( services: string | string[], options: IDockerComposeLogOptions = {} ): Promise { - let args = Array.isArray(services) ? services : [services] + const args = Array.isArray(services) ? services : [services] if (options.follow) { - args = ['--follow', ...args] + args.unshift('--follow') + } + if (options.timestamps) { + args.unshift('--timestamps') } return execCompose('logs', args, options) diff --git a/test/compose.test.ts b/test/compose.test.ts index 2c41d710..c0774e40 100644 --- a/test/compose.test.ts +++ b/test/compose.test.ts @@ -890,6 +890,19 @@ describe('logs command', (): void => { expect(std.out.includes('compose_test_proxy')).toBeTruthy() await compose.downAll({ cwd: path.join(__dirname), log: logOutput }) }) + + it('does include timestamps', async (): Promise => { + await compose.upAll({ cwd: path.join(__dirname), log: logOutput }) + const std = await compose.logs('proxy', { + cwd: path.join(__dirname), + log: logOutput, + timestamps: true + }) + + const currentDate = new Date().toISOString().slice(0, 10) + expect(std.out.includes(currentDate)).toBeTruthy() + await compose.downAll({ cwd: path.join(__dirname), log: logOutput }) + }) }) describe('port command', (): void => {