diff --git a/utils/scripts/types-move.js b/utils/scripts/types-move.js index f5610fd..95a7fa8 100644 --- a/utils/scripts/types-move.js +++ b/utils/scripts/types-move.js @@ -35,6 +35,24 @@ const loadFilesToCopy = async (target, typePath) => { return { target, files }; }; +/** + * Copies a types file and fixes any path to reference files it may contain. + * + * @param {string} filepath The path to the types file. + * @param {string} destination The path where the file should be copied to. + * @param {string} distanceToRoot The distance from the new path to the root. This is + * needed in order to replace paths to `@types`' + * references. + * @returns {Promise} + */ +const processFile = async (filepath, destination, distanceToRoot) => { + let contents = await fs.readFile(filepath, 'utf-8'); + contents = contents.replace( + /(