diff --git a/src/eoc.js b/src/eoc.js index d8dbae9e..7305a273 100755 --- a/src/eoc.js +++ b/src/eoc.js @@ -106,7 +106,8 @@ program .option('-c, --clean', 'Delete .eoc directory before running a command') .option('--debug', 'Print ALL debug messages, heavily overloading the log') .option('--verbose', 'Print debug messages and full output of child processes') - .option('--pin ', 'Fail if eoc version doesn\'t match exactly', version.what); + .option('--pin ', 'Fail if eoc version doesn\'t match exactly', version.what) + .option('--update-snapshots', 'Update snapshots in the local repository if they are outdated'); program.command('audit') .description('Inspect all packages and report their status') diff --git a/src/mvnw.js b/src/mvnw.js index 5a2521ed..d3d61183 100644 --- a/src/mvnw.js +++ b/src/mvnw.js @@ -50,6 +50,7 @@ module.exports.flags = function (opts) { opts.verbose ? '--errors' : '', opts.verbose ? '' : '--quiet', opts.debug ? '--debug' : '', + opts.updateSnapshots ? '--update-snapshots' : '', `-Deo.sourcesDir=${sources}`, `-Deo.targetDir=${target}`, `-Deo.outputDir=${path.resolve(opts.target, 'classes')}`, @@ -82,7 +83,6 @@ module.exports.mvnw = function (args, tgt, batch) { const params = args.filter((t) => t !== '').concat([ '--batch-mode', '--color=never', - '--update-snapshots', '--fail-fast', '--strict-checksums', ]); diff --git a/test/commands/test_print.js b/test/commands/test_print.js index acc430c9..fe7827d1 100644 --- a/test/commands/test_print.js +++ b/test/commands/test_print.js @@ -3,25 +3,32 @@ * SPDX-License-Identifier: MIT */ +const assert = require('assert'); const fs = require('fs'); const path = require('path'); const {runSync, assertFilesExist, parserVersion, homeTag, weAreOnline} = require('../helpers'); +const content = [ + '', + '', + '' +].join(' '); + +function setup(dir) { + const home = path.resolve(`temp/test-print/${dir}`); + fs.rmSync(home, {recursive: true, force: true}); + fs.mkdirSync(path.resolve(home, 'target/input'), {recursive: true}); + fs.writeFileSync( + path.resolve(home, 'target/input/foo.xmir'), + content + ); + return home; +} describe('print', () => { before(weAreOnline); it('converts XMIR files to EO files', (done) => { - const home = path.resolve('temp/test-print/simple'); - fs.rmSync(home, {recursive: true, force: true}); - fs.mkdirSync(path.resolve(home, 'target/input'), {recursive: true}); - fs.writeFileSync( - path.resolve(home, 'target/input/foo.xmir'), - [ - '', - '', - '' - ].join(' ') - ); + const home = setup('simple'); const stdout = runSync([ 'print', '--verbose', @@ -40,4 +47,39 @@ describe('print', () => { ); done(); }); + it('does not add --update--snapshots option if not requested', (done) => { + const home = setup('without-us'); + const stdout = runSync([ + 'print', + '--verbose', + '--track-transformation-steps', + `--parser=${parserVersion}`, + `--home-tag=${homeTag}`, + '--print-input=input', + '--print-output=output', + '-t', path.resolve(home, 'target'), + ]); + assert( + !stdout.includes('--update-snapshots'), + `Expected --update-snapshots option to not be included in the command when not requested:\n ${stdout}`); + done(); + }); + it('adds --update--snapshots option if requested', (done) => { + const home = setup('with-us'); + const stdout = runSync([ + 'print', + '--verbose', + '--track-transformation-steps', + `--parser=${parserVersion}`, + `--home-tag=${homeTag}`, + '--print-input=input', + '--print-output=output', + '--update-snapshots', + '-t', path.resolve(home, 'target'), + ]); + assert( + stdout.includes('--update-snapshots'), + `Expected --update-snapshots option to be included in the command when requested:\n ${stdout}`); + done(); + }); });