Skip to content

Commit

Permalink
chore(schematics/testing): add voice notification when finished a tas…
Browse files Browse the repository at this point in the history
…k - when passed optional flag `--voice-notify`
  • Loading branch information
Platonn committed Jan 30, 2025
1 parent c4753f6 commit 7317c78
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/schematics/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ const commands = [
] as const;
type Command = (typeof commands)[number];

const isVoiceNotifyEnabled = process.argv.includes('--voice-notify');
if (isVoiceNotifyEnabled) {
console.log('Voice notifications enabled');
}
function voiceAlert(message: string): void {
if (isVoiceNotifyEnabled) {
try {
execSync(`say "${message}"`);
} catch (error) {
console.warn('Voice notification failed:', error);
}
}
}

const buildLibRegEx = new RegExp('build (.*?)/schematics');
const verdaccioRegistryUrl = 'http://localhost:4873/';
const originalRegistryUrl = execSync('npm config get @spartacus:registry')
Expand Down Expand Up @@ -204,9 +218,11 @@ async function executeCommand(command: Command): Promise<void> {
switch (command) {
case 'publish':
publishLibs();
voiceAlert('Publishing completed');
break;
case 'build projects/schematics':
buildSchematics({ publish: true });
voiceAlert('Schematics build completed');
break;
case 'build asm/schematics':
case 'build cart/schematics':
Expand Down Expand Up @@ -240,12 +256,15 @@ async function executeCommand(command: Command): Promise<void> {
const lib =
buildLibRegEx.exec(command)?.pop() ?? 'LIB-REGEX-DOES-NOT-MATCH';
buildSchematicsAndPublish(`npm run build:${lib}`);
voiceAlert(`Schematics build of lib ${lib} completed`);
break;
case 'build all libs':
buildLibs();
voiceAlert('All libraries build completed');
break;
case 'test all schematics':
testAllSchematics();
voiceAlert('All schematics tests completed');
break;
case 'exit':
beforeExit();
Expand Down

0 comments on commit 7317c78

Please sign in to comment.