Skip to content

Commit

Permalink
Use the file order from manifest.json
Browse files Browse the repository at this point in the history
  • Loading branch information
monkbroc committed Dec 18, 2024
1 parent 739097f commit 4488125
Showing 1 changed file with 12 additions and 29 deletions.
41 changes: 12 additions & 29 deletions src/cmd/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ module.exports = class FlashCommand extends CLICommandBase {
} 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(/^\//, '');

Expand Down Expand Up @@ -140,11 +142,11 @@ module.exports = class FlashCommand extends CLICommandBase {

// const baseDir = path.join(path.dirname(manifestPath), parsed.base);
const baseDir = parsed.base;
const filesToProgram = await this._getFilesInOrder({
programXml: parsed.programXml,
patchXml: parsed.patchXml.map,
firehoseElf: parsed.firehose
});
const filesToProgram = [
parsed.firehose,
...parsed.programXml,
...parsed.patchXml
];

return { baseDir, filesToProgram };
}
Expand All @@ -157,12 +159,11 @@ module.exports = class FlashCommand extends CLICommandBase {
const parsed = this._parseManfiestData(data);

const baseDir = parsed.base;

const filesToProgram = await this._getFilesInOrder({
programXml: parsed.programXml,
patchXml: parsed.patchXml,
firehoseElf: parsed.firehose
});
const filesToProgram = [
parsed.firehose,
...parsed.programXml,
...parsed.patchXml
];

return { baseDir, filesToProgram };
}
Expand Down Expand Up @@ -192,24 +193,6 @@ module.exports = class FlashCommand extends CLICommandBase {
};
}

async _getFilesInOrder({ programXml, patchXml, firehoseElf }) {
if (!firehoseElf) {
throw new Error('Unable to find firehose file');
}
if (programXml.length === 0) {
throw new Error('Unable to find program xml files');
}
let files = [
firehoseElf,
...programXml.flatMap((programFile, i) => [
programFile,
patchXml[i]
].filter(Boolean))
].filter(Boolean);

return files;
}

async flashOverUsb({ binary, factory }) {
if (utilities.getFilenameExt(binary) === '.zip') {
throw new Error("Use 'particle flash --local' to flash a zipped bundle.");
Expand Down

0 comments on commit 4488125

Please sign in to comment.