MCPcopy Create free account
hub / github.com/continuedev/continue / validateFilesPresent

Function validateFilesPresent

scripts/util/index.js:42–100  ·  view source on GitHub ↗
(pathsToVerify)

Source from the content-addressed store, hash-verified

40}
41
42function validateFilesPresent(pathsToVerify) {
43 // This script verifies after pacakging that necessary files are in the correct locations
44 // In many cases just taking a sample file from the folder when they are all roughly the same thing
45
46 let missingFiles = [];
47 let emptyFiles = [];
48 for (const path of pathsToVerify) {
49 if (!fs.existsSync(path)) {
50 const parentFolder = path.split("/").slice(0, -1).join("/");
51 const grandparentFolder = path.split("/").slice(0, -2).join("/");
52 const grandGrandparentFolder = path.split("/").slice(0, -3).join("/");
53
54 console.error(`File ${path} does not exist`);
55 if (!fs.existsSync(parentFolder)) {
56 console.error(`Parent folder ${parentFolder} does not exist`);
57 } else {
58 console.error(
59 "Contents of parent folder:",
60 fs.readdirSync(parentFolder),
61 );
62 }
63 if (!fs.existsSync(grandparentFolder)) {
64 console.error(`Grandparent folder ${grandparentFolder} does not exist`);
65 if (!fs.existsSync(grandGrandparentFolder)) {
66 console.error(
67 `Grandgrandparent folder ${grandGrandparentFolder} does not exist`,
68 );
69 } else {
70 console.error(
71 "Contents of grandgrandparent folder:",
72 fs.readdirSync(grandGrandparentFolder),
73 );
74 }
75 } else {
76 console.error(
77 "Contents of grandparent folder:",
78 fs.readdirSync(grandparentFolder),
79 );
80 }
81
82 missingFiles.push(path);
83 }
84
85 if (fs.existsSync(path) && fs.statSync(path).size === 0) {
86 console.error(`File ${path} is empty`);
87 emptyFiles.push(path);
88 }
89 }
90
91 if (missingFiles.length > 0 || emptyFiles.length > 0) {
92 throw new Error(
93 `The following files were missing:\n- ${missingFiles.join(
94 "\n- ",
95 )}\n\nThe following files were empty:\n- ${emptyFiles.join("\n- ")}`,
96 );
97 } else {
98 console.log("All paths exist");
99 }

Callers 3

packageFunction · 0.85
prepackage.jsFile · 0.85
build.jsFile · 0.85

Calls 3

errorMethod · 0.80
pushMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected