From 6d2d0e426195e258f5bf64263c1286e86d6146a0 Mon Sep 17 00:00:00 2001 From: Julien Vanier Date: Wed, 18 Dec 2024 17:25:45 -0500 Subject: [PATCH] Update flash from a directory --- src/cmd/flash.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/cmd/flash.js b/src/cmd/flash.js index 1214ebdaa..8b8ad7cda 100644 --- a/src/cmd/flash.js +++ b/src/cmd/flash.js @@ -87,27 +87,20 @@ module.exports = class FlashCommand extends CLICommandBase { let filesToProgram; if (stats.isDirectory()) { - updateFolder = path.dirname(input); + updateFolder = input; const dirInfo = await this._extractFlashFilesFromDir(input); - includeDir = path.join(path.basename(input), dirInfo.baseDir); - filesToProgram = dirInfo.filesToProgram; + includeDir = dirInfo.baseDir; + filesToProgram = dirInfo.filesToProgram.map((file) => path.join(includeDir, file)); } else if (utilities.getFilenameExt(input) === '.zip') { updateFolder = path.dirname(input); zipFile = path.basename(input); const zipInfo = await this._extractFlashFilesFromZip(input); - includeDir = path.normalize(zipInfo.baseDir); - filesToProgram = zipInfo.filesToProgram; + includeDir = zipInfo.baseDir; + filesToProgram = zipInfo.filesToProgram.map((file) => path.join(includeDir, file)); } else { filesToProgram = files; } - // TODO: we shouldn't have to remove slashes. In what situation is this code necessary? - // remove the first / from the update folder and all the files - includeDir = includeDir.replace(/^\//, ''); - - filesToProgram = filesToProgram.map((file) => path.join(includeDir, file)); - filesToProgram = filesToProgram.map((file) => file.replace(/^\//, '')); - this.ui.write(`Starting download. The download may take several minutes...${os.EOL}`); const res = await qdl.run({ @@ -139,8 +132,7 @@ module.exports = class FlashCommand extends CLICommandBase { const data = await this._loadManifestFromFile(manifestPath); const parsed = this._parseManfiestData(data); - // const baseDir = path.join(path.dirname(manifestPath), parsed.base); - const baseDir = parsed.base; + const baseDir = path.normalize(parsed.base); const filesToProgram = [ parsed.firehose, ...parsed.programXml, @@ -157,7 +149,7 @@ module.exports = class FlashCommand extends CLICommandBase { const data = await this._loadManifestFromZip(zipPath); const parsed = this._parseManfiestData(data); - const baseDir = parsed.base; + const baseDir = path.normalize(parsed.base); const filesToProgram = [ parsed.firehose, ...parsed.programXml,