@icgio/clients-config 1.0.297 → 1.0.299

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/clients-config",
3
- "version": "1.0.297",
3
+ "version": "1.0.299",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
Binary file
@@ -1,9 +1,24 @@
1
1
  const fs = require('fs')
2
+ const { exec } = require('child_process')
2
3
  const prompt = require('prompt')
3
4
 
4
5
  const config_file_path = './config.json'
5
6
  const config_archive_file_path = './config-archive.json'
6
7
 
8
+ function run_prettier(file_path) {
9
+ return new Promise((resolve, reject) => {
10
+ exec(`npx prettier --write ${file_path}`, (error, stdout, stderr) => {
11
+ if (error) {
12
+ console.error(`Prettier error: ${error.message}`)
13
+ reject(error)
14
+ } else {
15
+ console.log(`Prettier formatted: ${file_path}`)
16
+ resolve()
17
+ }
18
+ })
19
+ })
20
+ }
21
+
7
22
  prompt.start()
8
23
 
9
24
  function read_config_file(path) {
@@ -86,6 +101,7 @@ function delete_client(client_name) {
86
101
  }
87
102
 
88
103
  write_config_file(config_file_data, config_file_path)
104
+ .then(() => run_prettier(config_file_path))
89
105
  .then(() => {
90
106
  console.log(`Client '${client_name}' has been deleted successfully.`)
91
107
  })
@@ -192,6 +208,7 @@ function add_client(client_name) {
192
208
  config_file_data.client_telegram_ids = sort(config_file_data.client_telegram_ids)
193
209
 
194
210
  write_config_file(config_file_data, config_file_path)
211
+ .then(() => run_prettier(config_file_path))
195
212
  .then(() => {
196
213
  console.log(`Client '${client_name}' has been added successfully.`)
197
214
  })
@@ -251,6 +268,7 @@ function update_config_archive(config_file_data, client_name) {
251
268
  }
252
269
 
253
270
  write_config_file(config_archive_data, config_archive_file_path)
271
+ .then(() => run_prettier(config_archive_file_path))
254
272
  .then(() => {
255
273
  resolve()
256
274
  })