From 238f99838ac7c651761960e9f2df19fb01827f00 Mon Sep 17 00:00:00 2001 From: Eden Date: Thu, 25 Oct 2018 13:19:16 -0400 Subject: [PATCH] Add PACKAGE_JSON_INDENT setting Allow custom number of indent spaces when regenerating package.json --- README.md | 1 + src/components/auto-increase-version/auto-increase-version.js | 2 +- src/config.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fdd4993..9a4bf3f 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ module.exports = { SHORT: 'CUSTOM', SILENT: false, PACKAGE_JSON_PATH: './package.json', + PACKAGE_JSON_INDENT: 4, components: { AutoIncreaseVersion: true, InjectAsComment: true, diff --git a/src/components/auto-increase-version/auto-increase-version.js b/src/components/auto-increase-version/auto-increase-version.js index 52e323b..08ff4f1 100644 --- a/src/components/auto-increase-version/auto-increase-version.js +++ b/src/components/auto-increase-version/auto-increase-version.js @@ -91,7 +91,7 @@ export default class AutoIncreaseVersion { this.packageFile.version = newVersion; fs.writeFile( path.resolve(this.context.config.PACKAGE_JSON_PATH), - JSON.stringify(this.packageFile, null, 4), (err) => { + JSON.stringify(this.packageFile, null, this.context.config.PACKAGE_JSON_INDENT), (err) => { if (err) { this.reject(err); console.log(err); diff --git a/src/config.js b/src/config.js index d7c2adc..192b3ab 100644 --- a/src/config.js +++ b/src/config.js @@ -2,6 +2,7 @@ export default { SHORT: 'AIV_SHORT', SILENT: false, PACKAGE_JSON_PATH: './package.json', + PACKAGE_JSON_INDENT: 4, components: { AutoIncreaseVersion: true, InjectAsComment: true,