From 415bfa42f4b480713dad13d3b0445d0d4bd29079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86gir=20=C3=96rn=20S=C3=ADmonarson?= Date: Tue, 4 Apr 2017 20:46:54 +0000 Subject: [PATCH] feat: only sort unsorted package.json file. (#14) --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c571d591..a2b4c8cc 100755 --- a/index.js +++ b/index.js @@ -119,6 +119,9 @@ if (require.main === module) { var fs = require('fs'); var packageJsonPath = process.cwd() + '/package.json'; var packageJson = fs.readFileSync(packageJsonPath, 'utf8'); - fs.writeFileSync(packageJsonPath, sortPackageJson(packageJson), 'utf8'); - console.log('Ok, your package.json is sorted'); + var sorted = sortPackageJson(packageJson); + if (sorted !== packageJson) { + fs.writeFileSync(packageJsonPath, sorted, 'utf8'); + console.log('Ok, your package.json is sorted'); + } }