MCPcopy Index your code
hub / github.com/prettydiff/prettydiff / dirComplete

Function dirComplete

services.ts:2300–2447  ·  view source on GitHub ↗
(list:directoryList)

Source from the content-addressed store, hash-verified

2298 hashlist:boolean = false;
2299 const http:RegExp = (/^https?:\/\//),
2300 dirComplete = function node_apps_hash_dirComplete(list:directoryList):void {
2301 let a:number = 0,
2302 c:number = 0;
2303 const listlen:number = list.length,
2304 listObject:any = {},
2305 hashes:string[] = [],
2306 hashComplete = function node_apps_hash_dirComplete_hashComplete():void {
2307 const hash:Hash = node.crypto.createHash("sha512");
2308 let hashstring:string = "";
2309 if (verbose === true) {
2310 console.log(`${apps.humantime(false)}File hashing complete. Working on a final hash to represent the directory structure.`);
2311 }
2312 hash.update(hashes.join(""));
2313 hashstring = (hashlist === true)
2314 ? JSON.stringify(listObject)
2315 : hash.digest("hex").replace(/\s+$/, "");
2316 if (verbose === true) {
2317 apps.log([`Pretty Diff hashed ${text.cyan + filepath + text.none}`], hashstring, filepath);
2318 }else{
2319 apps.log([""], hashstring, filepath);
2320 }
2321 },
2322 hashback = function node_apps_hash_dirComplete_hashback(data:readFile, item:string|Buffer, callback:Function):void {
2323 const hash:Hash = node.crypto.createHash("sha512");
2324 hash.on("readable", function node_apps_hash_dirComplete_hashback_hash():void {
2325 let hashstring:string = "";
2326 const hashdata:Buffer = <Buffer>hash.read();
2327 if (hashdata !== null) {
2328 hashstring = hashdata.toString("hex").replace(/\s+/g, "");
2329 callback(hashstring, data.index);
2330 }
2331 });
2332 hash.write(item);
2333 hash.end();
2334 if (http.test(filepath) === true) {
2335 apps.remove(data.path, function node_apps_hash_dirComplete_hashback_hash_remove():boolean {
2336 return true;
2337 });
2338 }
2339 },
2340 typeHash = function node_apps_hash_dirComplete_typeHash(index:number, end:number) {
2341 const terminate = function node_apps_hash_dirComplete_typeHash_terminate():void {
2342 c = c + 1;
2343 if (c === end) {
2344 if (a === listlen) {
2345 hashComplete();
2346 } else {
2347 if (verbose === true) {
2348 console.log(`${apps.humantime(false)}${text.green + apps.commas(a) + text.none} files hashed so far...`);
2349 }
2350 c = 0;
2351 recurse();
2352 }
2353 }
2354 };
2355 if (list[index][1] === "directory" || list[index][1] === "link") {
2356 const hash:Hash = node.crypto.createHash("sha512");
2357 hash.update(list[index][0]);

Callers 1

services.tsFile · 0.85

Calls 3

hashCompleteFunction · 0.85
hashbackFunction · 0.85
recurseFunction · 0.85

Tested by

no test coverage detected