From 8cb36675749cf3955f9174f917fd5d0d097647e0 Mon Sep 17 00:00:00 2001 From: ILGIN KANAT Date: Sun, 4 May 2025 22:01:08 +0400 Subject: [PATCH] Refactor update script to replace styleText with chalk for consistent logging --- update.mjs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/update.mjs b/update.mjs index a996380..dfd1162 100755 --- a/update.mjs +++ b/update.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { spawn } from 'child_process' import { argv } from 'process'; -import { styleText } from 'util'; +import chalk from 'chalk'; // ✅ Buraya dikkat let runCmd = (commandString) => new Promise((resolve, reject) => { let cmd = spawn(commandString, { shell: true, env: process.env }) @@ -10,7 +10,7 @@ let runCmd = (commandString) => new Promise((resolve, reject) => { cmd.stdout.on('data', (data) => { stdoutData += data process.stdout.write(data) -}) + }) cmd.stderr.on('data', (data) => process.stderr.write(data)) cmd.on('error', (e) => reject(e)) cmd.on('close', (e) => e == 0 ? resolve(stdoutData) : reject(`Return code: ${e}`)) @@ -18,32 +18,32 @@ let runCmd = (commandString) => new Promise((resolve, reject) => { let platform = process.platform.replace(/32$/, '').replace('darwin', 'mac') -console.log(styleText(['magenta', 'bold'], 'Updating Project')) +console.log(chalk.magenta.bold('Updating Project')) // ✅ styleText yerine await runCmd('git pull') await runCmd('git submodule update --init --recursive') -console.log(styleText(['magenta', 'bold'], 'Updating UI')) +console.log(chalk.magenta.bold('Updating UI')) process.chdir('ui') await runCmd('npm i') -console.log(styleText(['magenta', 'bold'], 'Updating API')) +console.log(chalk.magenta.bold('Updating API')) process.chdir('../api') await runCmd('npm i') -console.log(styleText(['magenta', 'bold'], 'Updating Electron')) +console.log(chalk.magenta.bold('Updating Electron')) process.chdir('../electron') await runCmd(`npm i`) process.chdir('..') if (argv.includes('--webbluetooth')) { - console.log(styleText(['magenta', 'bold'], 'Updating Subproject webbluetooth')) + console.log(chalk.magenta.bold('Updating Subproject webbluetooth')) process.chdir('api/webbluetooth') await runCmd('npm i') await runCmd('npm run build:all') process.chdir('../..') } -console.log(styleText(['magenta', 'bold'], 'Updating Subproject meshtastic-js')) +console.log(chalk.magenta.bold('Updating Subproject meshtastic-js')) process.chdir('api/meshtastic-js') await runCmd('npm i') await runCmd('npm run build')