将文件夹从 node js 项目目录内部复制到指定目录

时间:2021-05-10 06:02:15

标签: node.js

所以,我正在构建自己的节点 js 模块。我自己的 node js 模块将全局安装,我希望它能够将文件夹或文件从其目录中复制到指定的文件夹。我怎样才能做到这一点?

我已经尝试使用 fsclass Node { constructor(value, next=null) { this.value = value; this.next = next; } } function quickSort(head, tail) { if (tail == null || head == null || head == tail) return head; let pivot = tail; let curr = head; let prev = null; while (curr != pivot) { let next = curr.next; if (curr.value > pivot.value) { // Move node after tail if (prev == null) { head = next; } else { prev.next = next; } curr.next = tail.next; tail.next = curr; tail = curr; } else { prev = curr; } curr = next; } // Sort right and left sublists with recursion if (pivot != tail) pivot.next = quickSort(pivot.next, tail); return quickSort(head, prev); } // Some helper/utility functions function getTail(head) { if (head == null) return null; while (head.next != null) { head = head.next; } return head; } function createList(arr) { let head = null; for (let i = arr.length - 1; i >= 0; i--) { head = new Node(arr[i], head); } return head; } function toArray(head) { let arr = []; while (head != null) { arr.push(head.value); head = head.next; } return arr; } // Demo: // Create list from array let head = createList([4,2,6,1,5,3]); // Apply quick sort let tail = getTail(head); head = quickSort(head, tail); // Print console.log(toArray(head));,但它返回了错误:

enter image description here

顺便说一句,这些是我要复制的目录:

directories

0 个答案:

没有答案