MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / removeRecursive

Function removeRecursive

scripts/utils.js:104–127  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

102}
103
104export function removeRecursive(filePath) {
105 try {
106 if (fs.existsSync(filePath)) {
107 if (isFile(filePath)) {
108 fs.unlinkSync(filePath);
109 return;
110 }
111 const files = fs.readdirSync(filePath);
112 for (let i = 0; i < files.length; i++) {
113 const childPath = path.resolve(filePath, files[i]);
114 if (isDir(childPath)) {
115 removeRecursive(childPath);
116 } else {
117 fs.unlinkSync(childPath);
118 }
119 }
120 fs.rmdirSync(filePath);
121 }
122 } catch (error) {
123 throw new Error(
124 `Received an error: [${error}] while trying to remove: ${filePath}`,
125 );
126 }
127}
128
129export function includes(sequence, target) {
130 return sequence.indexOf(target) > -1;

Callers

nothing calls this directly

Calls 3

isFileFunction · 0.85
isDirFunction · 0.85
resolveMethod · 0.65

Tested by

no test coverage detected