Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/base/cache-cli.ts
13388 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import path from 'path';
7
import { Cache } from './cache';
8
9
async function main() {
10
const args = process.argv.slice(2);
11
12
if (args.length < 1) {
13
console.log('Usage:');
14
console.log(' npx tsx cache-cli check - Check if there are any duplicate keys in the databases');
15
process.exit(1);
16
}
17
18
const cache = new Cache(path.resolve(__dirname, '..', 'simulation', 'cache'));
19
20
try {
21
switch (args[0]) {
22
case 'check': {
23
const result = await cache.checkDatabase();
24
if (result.size === 0) {
25
console.log('✅ No duplicate keys found.');
26
} else {
27
console.log('⛔ Duplicate keys found:');
28
for (const [key, values] of result) {
29
console.log(` - "${key}" found in: `, values.join(', '));
30
}
31
throw new Error('Duplicate keys found in the database.');
32
}
33
break;
34
}
35
default: {
36
console.error('Invalid command. Use: check');
37
process.exit(1);
38
}
39
}
40
} catch (error) {
41
console.error('⛔ Error:', error);
42
process.exit(1);
43
}
44
}
45
46
// Run main function if this file is executed directly
47
if (require.main === module) {
48
main();
49
}
50