From 6a05b7307c6b4b9de36ead754be735b0b9748c65 Mon Sep 17 00:00:00 2001 From: Juan Campa Date: Thu, 9 May 2019 18:31:11 +0000 Subject: [PATCH] Ignore line endings when comparing config file against default (#3645) --- app/config/import.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/config/import.js b/app/config/import.js index c779d72c..678dc3d6 100644 --- a/app/config/import.js +++ b/app/config/import.js @@ -55,16 +55,20 @@ const migrateHyper2Config = () => { return; } - const hasNewConfigBeenTouched = existsNew && readFileSync(cfgPath, 'utf8') !== readFileSync(defaultCfg, 'utf8'); - if (hasNewConfigBeenTouched) { - // Assume the user has migrated manually but rename old config to .backup so - // we don't keep trying to migrate on every launch - const backupPath = saveAsBackup(legacyCfgPath); - notify( - 'Hyper 3', - `Settings location has changed to ${cfgPath}.\nWe've backed up your old Hyper config to ${backupPath}` - ); - return; + if (existsNew) { + const cfg1 = readFileSync(defaultCfg, 'utf8').replace(/\r|\n/g, ''); + const cfg2 = readFileSync(cfgPath, 'utf8').replace(/\r|\n/g, ''); + const hasNewConfigBeenTouched = cfg1 !== cfg2; + if (hasNewConfigBeenTouched) { + // Assume the user has migrated manually but rename old config to .backup so + // we don't keep trying to migrate on every launch + const backupPath = saveAsBackup(legacyCfgPath); + notify( + 'Hyper 3', + `Settings location has changed to ${cfgPath}.\nWe've backed up your old Hyper config to ${backupPath}` + ); + return; + } } // Migrate