intradoc
Version:
In-place document content replacer CLI utility.
36 lines (32 loc) • 948 B
JavaScript
;
var node_path = require('node:path');
var index = require('../utils/index.js');
const loadFiles = async (options) => {
const loadedFiles = [];
const cwd = options.cwd;
for await (const file of options.files) {
const path = node_path.join(cwd, file);
if (!await index.fileExists(path)) {
const error = new Error(`File "${path}" doesn't exist.`);
error.$metadata = {
cwd,
path,
file
};
throw error;
}
const { content } = await index.loadFile(path);
loadedFiles.push({
filepath: path,
dirpath: node_path.dirname(path),
filename: node_path.basename(path),
content
});
}
return {
files: loadedFiles,
numFiles: loadedFiles.length
};
};
exports.loadFiles = loadFiles;
//# sourceMappingURL=loadFiles.js.map