typescript-file-copy-plugin
Version:
[](https://www.npmjs.com/package/typescript-file-copy-plugin)  [ {
if (!options.copy || !Array.isArray(options.copy)) {
throw new Error("The 'copy' parameter must be defined and be an array.");
}
options.copy.forEach((config, index) => {
if (!config.src) {
throw new Error(`The 'src' property is missing in the copy config at index ${index}.`);
}
if (!config.dest) {
throw new Error(`The 'dest' property is missing in the copy config at index ${index}.`);
}
});
}
function createCopyFilesTransformer(program, options) {
return (context) => (sourceFile) => {
return sourceFile;
};
}
function copyFilesPostCompilation(program, options) {
const copiedPaths = /* @__PURE__ */ new Set();
const origEmit = program.emit;
program.emit = (...args) => {
const result = origEmit(...args);
for (const config of options.copy) {
const resolvedDest = resolve(config.dest);
if (!copiedPaths.has(resolvedDest)) {
if (existsSync(config.src) && statSync(config.src).isFile() && extname(config.dest)) {
mkdirpSync(dirname(resolvedDest));
copyFileSync(config.src, resolvedDest);
} else {
copySync(config.src, config.dest);
}
copiedPaths.add(resolvedDest);
}
}
return result;
};
}
function src_default(program, pluginOptions) {
validateOptions(pluginOptions);
copyFilesPostCompilation(program, pluginOptions);
return createCopyFilesTransformer(program, pluginOptions);
}
export {
src_default as default
};
//# sourceMappingURL=index.mjs.map