From 0207df207d7aeda2c2a5cb1c451e410a0ed3bcbe Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 9 Jul 2019 09:59:41 +0200 Subject: [PATCH] fix: skip sorting non package.json files --- lib/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index d30ae7c..1055f95 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,3 +1,4 @@ +const path = require('path') const { parsers } = require('prettier/parser-babylon') const sortPackageJson = require('sort-package-json') const parser = parsers['json-stringify'] @@ -9,7 +10,10 @@ exports.parsers = { if (parser.preprocess) { text = parser.preprocess(text, options) } - return sortPackageJson(text) + if (options.filepath && path.basename(options.filepath) === 'package.json') { + return sortPackageJson(text) + } + return text }, }, }