Skip to content

Commit

Permalink
feat(copy): add log for resetting when there is no data in the target…
Browse files Browse the repository at this point in the history
… account
  • Loading branch information
vaidik committed Jun 7, 2023
1 parent 749c4f2 commit c792bad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,17 @@ copy_cmd.action(async () => {
]);

if (yes || answers.continueReset) {
console.log(
'Resetting target GTM account and copying entities from source GTM account...'
.gray
);
if (targetAccount.isEmpty()) {
console.log(
'There is no data in the target GTM account to reset. Continuing to copy entities from source GTM account...'
.yellow
);
} else {
console.log(
'Resetting target GTM account and copying entities from source GTM account...'
.gray
);
}
await targetAccount.reset();
const responses = await targetAccount.copyDataFromAccount(sourceAccount);

Expand Down
4 changes: 4 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export class TagManagerData {
});
}

isEmpty(): boolean {
return !(this.variables.size || this.triggers.size || this.tags.size);
}

async copyVariable(
val: tagmanager_v2.Schema$Variable
): Promise<CopyResponse<tagmanager_v2.Schema$Variable>> {
Expand Down

0 comments on commit c792bad

Please sign in to comment.