@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 3.12 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/tools/wac-cli/src/angular15/upgrader/jasmine-test-upgrader.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,QAAQ,CAEd;IAEF;;;OAGG;gBACS,cAAc,EAAE,MAAM,EAAE,KAAK,UAAQ;IAMjD;;OAEG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4CpC","file":"jasmine-test-upgrader.d.ts","sourcesContent":["import { Logger } from '../utils/logger';\r\nimport { FileWriter } from '../utils/file-writer';\r\nimport { runCommand } from '../utils/command-runner';\r\nimport { adds } from '../configs/jasmine-test-config';\r\nimport { getRelativePath } from '../utils/relative-path';\r\n\r\n/**\r\n * The upgrader for the jamine test files(.spec.ts files)\r\n */\r\nexport class JasmineTestUpgrader {\r\n private fileWriter: FileWriter;\r\n private testTsFilePath: string;\r\n private debug = false;\r\n\r\n private messages = {\r\n notFound: ''\r\n };\r\n\r\n /**\r\n * the constructor.\r\n * @param filePath the file path.\r\n */\r\n constructor(testTsFilePath: string, debug = false) {\r\n this.messages.notFound = `No spec.ts file found.`;\r\n this.testTsFilePath = testTsFilePath;\r\n this.debug = debug;\r\n }\r\n\r\n /**\r\n * the run function to resolve the errors.\r\n */\r\n public async run(): Promise<void> {\r\n try {\r\n const getSpecFiles = 'dir /s /b src\\\\*.spec.ts';\r\n let specFiles = [];\r\n Logger.log(getSpecFiles);\r\n runCommand(getSpecFiles, this.debug, true).then(async (response) => {\r\n specFiles = response.split('\\r\\n');\r\n\r\n if (!specFiles.length) {\r\n Logger.log(this.messages.notFound);\r\n }\r\n\r\n specFiles = specFiles.filter(item => item.trim() !== \"\");\r\n console.log(specFiles);\r\n console.log(specFiles.length);\r\n\r\n for (let i = 0; i < specFiles.length; i++) {\r\n const specFile = specFiles[i];\r\n\r\n // Wait for 50ms\r\n await sleep(50);\r\n \r\n this.fileWriter = new FileWriter(specFile);\r\n\r\n this.fileWriter\r\n .addContent(adds, false, 0, '')\r\n .fixImportHandler(`import { setUpMock } from \"${getRelativePath(specFile, this.testTsFilePath).replace('.ts', '')}\";`)\r\n .writeFile();\r\n }\r\n\r\n /**\r\n * This function guarantees that MIMO on file system is not triggering race condition.\r\n * @param ms miliseconds\r\n * @returns \r\n */\r\n function sleep(ms) {\r\n return new Promise(resolve => setTimeout(resolve, ms));\r\n }\r\n });\r\n\r\n } catch (error) {\r\n Logger.error(error);\r\n }\r\n }\r\n}\r\n"]}