Skip to content

Commit

Permalink
minor clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Feb 4, 2025
1 parent a728fb5 commit b62a363
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/cmd/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = class FlashCommand extends CLICommandBase {

try {
if (verbose) {
this.ui.write(`Starting download. See logs at: ${outputLog}${os.EOL}`);
this.ui.write(`${os.EOL}Starting download. See logs at: ${outputLog}${os.EOL}`);
}
const qdl = new QdlFlasher({
files: filesToProgram,
Expand All @@ -114,10 +114,11 @@ module.exports = class FlashCommand extends CLICommandBase {
zip: zipFile,
ui: this.ui,
outputLogFile: outputLog,
skipReset
skipReset,
currTask: 'OS'
});
await qdl.run();
fs.appendFileSync(outputLog, 'OS Download complete.');
fs.appendFileSync(outputLog, `OS Download complete.${os.EOL}`);
} catch (error) {
fs.appendFileSync(outputLog, 'Download failed with error: ' + error.message);
throw new Error('Download failed with error: ' + error.message);
Expand All @@ -133,11 +134,12 @@ module.exports = class FlashCommand extends CLICommandBase {
const qdl = new QdlFlasher({
files: [firehoseFile, xmlFile],
ui: this.ui,
outputLogFile: output
outputLogFile: output,
currTask: 'Configuration file'
});

await qdl.run();
fs.appendFileSync(output, 'Config file download complete.');
fs.appendFileSync(output, `Config file download complete.${os.EOL}`);
} catch (error) {
fs.appendFileSync(output, 'Download failed with error: ' + error.message);
throw new Error('Download failed with error: ' + error.message);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/setup-tachyon.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ Welcome to the Particle Tachyon setup! This interactive command:
const outputLog = path.join(process.cwd(), `tachyon_flash_${Date.now()}.log`);
fs.ensureFileSync(outputLog);

this.ui.write(`Starting download. See logs at: ${outputLog}${os.EOL}`);
this.ui.write(`${os.EOL}Starting download. See logs at: ${outputLog}${os.EOL}`);
if (!skipFlashingOs) {
await flashCommand.flashTachyon({ files: [packagePath], skipReset: true, output: outputLog, verbose: false });
}
Expand Down
11 changes: 8 additions & 3 deletions src/lib/qdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const mkdirTemp = util.promisify(temp.mkdir);
const TACHYON_STORAGE_TYPE = 'ufs';

class QdlFlasher {
constructor({ files, includeDir, updateFolder, zip, ui, outputLogFile, skipReset=false }) {
constructor({ files, includeDir, updateFolder, zip, ui, outputLogFile, skipReset=false, currTask=null }) {
this.files = files;
this.includeDir = includeDir;
this.updateFolder = updateFolder;
Expand All @@ -25,17 +25,19 @@ class QdlFlasher {
this.progressBarInitialized = false;
this.preparingDownload = false;
this.skipReset = skipReset;
this.currTask = currTask;
}

async run() {
let qdlProcess;
try {
const qdlPath = await this.getExecutable();
const qdlArguments = this.buildArgs({ files: this.files, includeDir: this.includeDir, zip: this.zip });
this.progressBar = this.ui.createProgressBar();
const command = `${qdlPath} ${qdlArguments.join(' ')}`;
fs.appendFileSync(this.outputLogFile, `Command: ${command}\n`);

const qdlProcess = execa(qdlPath, qdlArguments, {
qdlProcess = execa(qdlPath, qdlArguments, {
cwd: this.updateFolder || process.cwd(),
stdio: 'pipe'
});
Expand All @@ -56,6 +58,9 @@ class QdlFlasher {
if (this.progressBarInitialized) {
this.progressBar.stop();
}
if (qdlProcess && qdlProcess.kill) {
qdlProcess.kill();
}
}
}

Expand Down Expand Up @@ -156,7 +161,7 @@ class QdlFlasher {
}

if (this.totalSectorsFlashed === this.totalSectorsInAllFiles) {
this.progressBar.update({ description: 'Flashing complete' });
this.progressBar.update({ description: `Flashing complete ${this.currTask ? this.currTask : ''}` });
}
}
}
Expand Down

0 comments on commit b62a363

Please sign in to comment.