Files
NapCatQQ/.pnpm-store/v3/files/77/3ebdb305f6e3695aee93814d00a25ab80fd756ea38411186045b0f847a211318395f21f7c1e2af417d3785be9eba8763149a3b84b4d9fb7ea55d0238938085
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

53 lines
1.3 KiB
Plaintext

'use strict';
var through = require('through2');
var readDir = require('./read-dir');
var readStream = require('./read-stream');
var readBuffer = require('./read-buffer');
var readSymbolicLink = require('./read-symbolic-link');
function readContents(optResolver) {
function readFile(file, enc, callback) {
// Skip reading contents if read option says so
var read = optResolver.resolve('read', file);
if (!read) {
return callback(null, file);
}
// Don't fail to read a directory
if (file.isDirectory()) {
return readDir(file, optResolver, onRead);
}
// Process symbolic links included with `resolveSymlinks` option
if (file.stat && file.stat.isSymbolicLink()) {
return readSymbolicLink(file, optResolver, onRead);
}
// Read and pass full contents
var buffer = optResolver.resolve('buffer', file);
if (buffer) {
return readBuffer(file, optResolver, onRead);
}
// Don't buffer anything - just pass streams
return readStream(file, optResolver, onRead);
// This is invoked by the various readXxx modules when they've finished
// reading the contents.
function onRead(readErr) {
if (readErr) {
return callback(readErr);
}
return callback(null, file);
}
}
return through.obj(readFile);
}
module.exports = readContents;