From 496c8f790f41b67c1949385a509b6c1c614fbf48 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 5 Jun 2020 22:59:07 +0100 Subject: [PATCH] Fix dev polyfill downloads in checkDevDependencies --- Sources/carton/Helpers/checkDevDependencies.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/carton/Helpers/checkDevDependencies.swift b/Sources/carton/Helpers/checkDevDependencies.swift index 8fdcd08..9dc47ae 100644 --- a/Sources/carton/Helpers/checkDevDependencies.swift +++ b/Sources/carton/Helpers/checkDevDependencies.swift @@ -47,12 +47,16 @@ func checkDevDependencies() throws { let devPolyfill = cartonDir.appending("static", "dev.js") // If dev.js hash fails, download the `static.zip` archive and unpack it/ - if try Data(contentsOf: devPolyfill).sha512 != devPolyfillHash { + if try !fm.fileExists( + atPath: devPolyfill.path + ) || Data(contentsOf: devPolyfill).sha512 != devPolyfillHash { + print("Downloading the polyfill archive from \(archiveURL)...") let downloadedArchive = try Data(contentsOf: archiveURL) let downloadedHash = downloadedArchive.sha512 try verifyHash(downloadedHash, archiveHash, context: archiveURL) let archiveFile = cartonDir.appending("static.zip") + try fm.createDirectory(at: cartonDir, withIntermediateDirectories: true) try downloadedArchive.write(to: archiveFile) try fm.unzipItem(at: archiveFile, to: cartonDir) }