A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/7b0542028f9c3cc326c26a1986c34cec7eb04931 below:

fdir@6.4.6 · npm/cli@7b05420 · GitHub

File tree Expand file treeCollapse file tree 12 files changed

+1416

-100

lines changed

Filter options

Expand file treeCollapse file tree 12 files changed

+1416

-100

lines changed Original file line number Diff line number Diff line change

@@ -7,11 +7,11 @@ exports.build = void 0;

7 7

const fs_1 = __importDefault(require("fs"));

8 8

const readdirOpts = { withFileTypes: true };

9 9

const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback) => {

10 +

state.queue.enqueue();

10 11

if (currentDepth < 0)

11 12

return state.queue.dequeue(null, state);

12 13

state.visited.push(crawlPath);

13 14

state.counts.directories++;

14 -

state.queue.enqueue();

15 15

// Perf: Node >= 10 introduced withFileTypes that helps us

16 16

// skip an extra fs.stat call.

17 17

fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {

Original file line number Diff line number Diff line change

@@ -14,10 +14,16 @@ class Queue {

14 14

}

15 15

enqueue() {

16 16

this.count++;

17 +

return this.count;

17 18

}

18 19

dequeue(error, output) {

19 -

if (--this.count <= 0 || error)

20 +

if (this.onQueueEmpty && (--this.count <= 0 || error)) {

20 21

this.onQueueEmpty(error, output);

22 +

if (error) {

23 +

output.controller.abort();

24 +

this.onQueueEmpty = undefined;

25 +

}

26 +

}

21 27

}

22 28

}

23 29

exports.Queue = Queue;

Original file line number Diff line number Diff line change

@@ -62,6 +62,7 @@ class Walker {

62 62

queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback)),

63 63

symlinks: new Map(),

64 64

visited: [""].slice(0, 0),

65 +

controller: new AbortController(),

65 66

};

66 67

/*

67 68

* Perf: We conditionally change functions according to options. This gives a slight

@@ -77,14 +78,16 @@ class Walker {

77 78

this.walkDirectory = walkDirectory.build(this.isSynchronous);

78 79

}

79 80

start() {

81 +

this.pushDirectory(this.root, this.state.paths, this.state.options.filters);

80 82

this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);

81 83

return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;

82 84

}

83 85

walk = (entries, directoryPath, depth) => {

84 -

const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, }, } = this.state;

85 -

if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))

86 +

const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, }, controller, } = this.state;

87 +

if (controller.signal.aborted ||

88 +

(signal && signal.aborted) ||

89 +

(maxFiles && paths.length > maxFiles))

86 90

return;

87 -

this.pushDirectory(directoryPath, paths, filters);

88 91

const files = this.getArray(this.state.paths);

89 92

for (let i = 0; i < entries.length; ++i) {

90 93

const entry = entries[i];

@@ -97,9 +100,10 @@ class Walker {

97 100

let path = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);

98 101

if (exclude && exclude(entry.name, path))

99 102

continue;

103 +

this.pushDirectory(path, paths, filters);

100 104

this.walkDirectory(this.state, path, path, depth - 1, this.walk);

101 105

}

102 -

else if (entry.isSymbolicLink() && this.resolveSymlink) {

106 +

else if (this.resolveSymlink && entry.isSymbolicLink()) {

103 107

let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);

104 108

this.resolveSymlink(path, this.state, (stat, resolvedPath) => {

105 109

if (stat.isDirectory()) {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4