{"version":3,"sources":["../../../packages/tools/wac-cli/src/upgrade/get-files.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAW;IAE/B;;;OAGG;WACiB,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;mBAQ9B,YAAY;CAiBpC","file":"get-files.d.ts","sourcesContent":["import { readdir, stat, Stats } from 'fs';\r\nimport { resolve } from 'path';\r\nimport { Common } from '../common';\r\n\r\nexport class CodeFilePaths {\r\n    private static files: string[];\r\n\r\n    /**\r\n     * Retrieves all code files from current repository.\r\n     * @returns {Promise<string[]>} Promise of array containing file paths\r\n     */\r\n    public static async initialize(): Promise<string[]> {\r\n        if (!CodeFilePaths.files) {\r\n            CodeFilePaths.files = await CodeFilePaths.searchFolder(Common.rootPath + '\\\\src\\\\app');\r\n        }\r\n\r\n        return new Promise(resolvePromise => resolvePromise(CodeFilePaths.files));\r\n    }\r\n\r\n    private static async searchFolder(folderPath: string): Promise<string[]> {\r\n        const subDirectories: string[] = await new Promise((resolvePromise, reject) =>\r\n            readdir(folderPath, null, (err, fileResults) => err ? reject(err) : resolvePromise(fileResults))\r\n        );\r\n\r\n        const files = await Promise.all(subDirectories.map(async (subDirectory) => {\r\n            const resource = resolve(folderPath, subDirectory);\r\n\r\n            const fileStatus: Stats = await new Promise((resolvePromise, reject) =>\r\n                stat(resource, (err, status) => err ? reject(err) : resolvePromise(status))\r\n            );\r\n\r\n            return fileStatus.isDirectory() ? this.searchFolder(resource) : resource;\r\n        }));\r\n\r\n        return Array.prototype.concat(...files);\r\n    }\r\n}\r\n"]}