MCPcopy Create free account
hub / github.com/SoCreate/angular-playground / deleteSnapshots

Function deleteSnapshots

projects/cli/src/check-snapshots.ts:90–121  ·  view source on GitHub ↗
(config: Config)

Source from the content-addressed store, hash-verified

88}
89
90function deleteSnapshots(config: Config) {
91 try {
92 const absoluteSnapshotDirectory = normalizeResolvePath(config.snapshotDirectory);
93 const items: SandboxFileInformation[] = require(SANDBOX_MENU_ITEMS_FILE).getSandboxMenuItems();
94 const buildIdentifier = (url) => {
95 return decodeURIComponent(url)
96 .substr(2)
97 .replace(/[\/.]|\s+/g, '-')
98 .replace(/[^a-z0-9\-]/gi, '');
99 };
100
101 let filesDeleted = false;
102 items.forEach((item) => {
103 item.scenarioMenuItems.forEach((scenarioItem) => {
104 if (!config.pathToSandboxes || config.pathToSandboxes.some(vp => item.key.includes(vp))) {
105 const url = `${encodeURIComponent(item.key)}/${encodeURIComponent(scenarioItem.description)}`;
106 const filePath = `${absoluteSnapshotDirectory}/${buildIdentifier(url)}-snap.png`;
107 if (existsSync(filePath)) {
108 unlinkSync(filePath);
109 console.log(`Deleted file: ${filePath}`);
110 filesDeleted = true;
111 }
112 }
113 });
114 });
115 if (!filesDeleted) {
116 console.log('No snapshots were deleted.');
117 }
118 } catch (err) {
119 throw new Error(`Failed to delete snapshots. ${err}`);
120 }
121}
122
123function writeSandboxesToTestFile(config: Config, hostUrl: string, testPath: string, viewportConfig?: ViewportOptions) {
124 const absoluteSnapshotDirectory = normalizeResolvePath(config.snapshotDirectory);

Callers 1

checkSnapshotsFunction · 0.85

Calls 3

normalizeResolvePathFunction · 0.85
buildIdentifierFunction · 0.85
getSandboxMenuItemsMethod · 0.45

Tested by

no test coverage detected