Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/mvnw.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ module.exports.mvnw = function(args, tgt, batch) {
return new Promise((resolve, reject) => {
target = tgt;
phase = args[0];
const jvmLogArgs = [
'-Dorg.slf4j.simpleLogger.showDateTime=true',
'-Dorg.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss'
];
const home = path.resolve(__dirname, '../mvnw'),
bin = path.resolve(home, 'mvnw') + (process.platform === 'win32' ? '.cmd' : ''),
params = args.filter((t) => t !== '').concat([
'--batch-mode',
'--color=never',
'--update-snapshots',
'--fail-fast',
'--strict-checksums',
]),
params = jvmLogArgs.concat(
args.filter((t) => t !== '').concat([
'--batch-mode',
'--color=never',
'--update-snapshots',
'--fail-fast',
'--strict-checksums',
])
),
cmd = `${bin } ${ params.join(' ')}`;
console.debug('+ %s', cmd);
const result = spawn(
Expand Down
26 changes: 26 additions & 0 deletions test/test_mvnw.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

const {mvnw, flags} = require('../src/mvnw');
const { spawn } = require('child_process');
const assert = require('assert');

describe('mvnw', () => {
Expand All @@ -25,4 +26,29 @@ describe('mvnw', () => {
done();
});
});

it('includes timestamps in Maven logs', (done) => {
const mvnwPath = require('path').resolve(__dirname, '../mvnw/mvnw');
const args = [
'-Dorg.slf4j.simpleLogger.showDateTime=true',
'-Dorg.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss',
'validate',
'--quiet'
];
const proc = spawn(mvnwPath, args);

let output = '';
proc.stdout.on('data', (data) => {
output += data.toString();
});
proc.stderr.on('data', (data) => {
output += data.toString();
});
proc.on('close', (code) => {
const lines = output.split('\n');
const hasTimestamp = lines.some(line => /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(line));
assert.ok(hasTimestamp, 'Maven output should include timestamps');
done();
});
});
});
Loading