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
2 changes: 1 addition & 1 deletion @types/lib/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,13 +1274,16 @@ export default class Mcdev {
return;
}

if (typeof Util.OPTIONS.purge !== 'boolean') {
if (typeof Util.OPTIONS.purge !== 'boolean' && !Util.OPTIONS.skipInteraction) {
// deploy folder is in targets for definition creation
// recommend to purge their content first
Util.OPTIONS.purge = await confirm({
message: `Do you want to empty relevant BU sub-folders in /${properties.directories.deploy} (ensures no files from previous deployments remain)?`,
default: true,
});
} else if (Util.OPTIONS.skipInteraction) {
// with --y/--yes, go with the default (purge = true)
Util.OPTIONS.purge = true;
}

const response = bulk
Expand Down
37 changes: 36 additions & 1 deletion test/general.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as chai from 'chai';
import { Util } from '../lib/util/util.js';
const assert = chai.assert;
const expect = chai.expect;

import chaiFiles from 'chai-files';
import * as testUtils from './utils.js';
import handler from '../lib/index.js';
import { Util } from '../lib/util/util.js';
import MetadataType from '../lib/metadataTypes/MetadataType.js';
import Asset from '../lib/metadataTypes/Asset.js';
import File from '../lib/util/file.js';
Expand Down Expand Up @@ -1304,6 +1304,41 @@ describe('GENERAL', () => {
);
});

it('build does not prompt for purge when skipInteraction is set', async () => {
// preparation
await handler.retrieve('testInstance/testBU', ['automation']);
const argvMetadata = ['automation:testExisting_automation'];
const typeKeyCombo = handler.metadataToTypeKey(argvMetadata);
const buName = 'testInstance/testBU';

// simulate --y / --yes
handler.setOptions({ skipInteraction: true });

// buildTemplate first, then build; if the confirm prompt fires
// here the test hangs (no TTY), proving the bug; with the fix
// it should complete and set purge to the default (true)
await handler.buildTemplate(buName, typeKeyCombo, undefined, ['testSourceMarket']);
await handler.build(
buName,
undefined,
typeKeyCombo,
['testSourceMarket'],
['deployment-target'],
true
);

assert.equal(process.exitCode, 0, 'build should not have thrown');
assert.strictEqual(
Util.OPTIONS.purge,
true,
'purge should default to true when skipInteraction is set'
);

// cleanup
handler.setOptions({ skipInteraction: undefined });
Util.OPTIONS.purge = undefined;
});

it('buildTemplate + buildDefinition for multiple types with keys and --dependencies and --retrieve', async () => {
// preparation
const argvMetadata = [
Expand Down