From 532e3ec5cd65b564ff52e63ca0ec402969a0720b Mon Sep 17 00:00:00 2001 From: eeue56 Date: Wed, 26 Oct 2016 01:24:13 +0200 Subject: [PATCH] only write if needed --- native_package_install.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/native_package_install.py b/native_package_install.py index d338140..34554ae 100755 --- a/native_package_install.py +++ b/native_package_install.py @@ -191,6 +191,8 @@ def update_elm_package(vendor_dir, configs, packages): source_directories = data['source-directories'] path = '../' * config.count('/') + needs_save = False + for package in packages: current_package_dirs = get_source_dirs(vendor_dir, package) @@ -199,9 +201,11 @@ def update_elm_package(vendor_dir, configs, packages): if relative_path not in data['source-directories']: data['source-directories'].append(relative_path) + needs_save = True - with open(config, 'w') as f: - f.write(json.dumps(data, indent=4)) + if needs_save: + with open(config, 'w') as f: + f.write(json.dumps(data, indent=4)) return repository