@qrvey/utils 1.2.10-3 → 1.2.10-4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/publishing.js +22 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.2.10-3",
3
+ "version": "1.2.10-4",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
package/publishing.js CHANGED
@@ -1,6 +1,4 @@
1
1
  // IN DEVELOPMENT
2
-
3
-
4
2
  const fs = require('fs');
5
3
  const util = require('util');
6
4
  const childProcess = require('child_process');
@@ -8,6 +6,7 @@ const exec = util.promisify(childProcess.exec);
8
6
  const spawn = childProcess.spawn;
9
7
  const proc = require('process');
10
8
  const readline = require("readline");
9
+ const { exit } = require('process');
11
10
  const rl = readline.createInterface({
12
11
  input: proc.stdin,
13
12
  output: proc.stdout
@@ -31,10 +30,10 @@ async function execute(command) {
31
30
  return response;
32
31
  }
33
32
 
34
- //todo: fix the spawning function to wait for the second process to finish and then continue the next code
35
33
  async function spawning(command, sArguments) {
36
- const newProcess = await new Promise(function (resolve, reject) {
37
- spawn(command, sArguments, { shell: true });
34
+ let newProcess;
35
+ await new Promise(function (resolve, reject) {
36
+ newProcess = spawn(command, sArguments, { shell: true });
38
37
  newProcess.stdout.on("data", data => {
39
38
  console.log(`stdout: ${data}`);
40
39
  });
@@ -43,17 +42,26 @@ async function spawning(command, sArguments) {
43
42
  console.log(`stderr: ${data}`);
44
43
  });
45
44
 
46
- newProcess.on('error', (error) => {
45
+ newProcess.on('error', (_error) => {
46
+ newProcess.stdin.pause();
47
+ newProcess.stdin.destroy();
48
+ newProcess.stdout.pause();
49
+ newProcess.stdout.destroy();
50
+ newProcess.kill();
47
51
  reject();
48
- throw new Error(error.message);
49
52
  });
50
53
 
51
54
  newProcess.on("close", code => {
55
+ newProcess.stdin.pause();
56
+ newProcess.stdin.destroy();
57
+ newProcess.stdout.pause();
58
+ newProcess.stdout.destroy();
59
+ newProcess.kill();
52
60
  if (code == '1') {
53
61
  reject();
54
- throw new Error(`child process exited with code ${code}`);
55
62
  }
56
63
  resolve();
64
+
57
65
  });
58
66
  });
59
67
  }
@@ -92,10 +100,11 @@ async function generatingDocument(settings) {
92
100
  async function pushingChanges(settings) {
93
101
  console.log('>>> Commiting and Pushing Docs changes...');
94
102
 
95
- const stdout = await execute('git rev-parse --abbrev-ref HEAD');
103
+ const gitStdout = await execute('git rev-parse --abbrev-ref HEAD');
104
+ console.log('gitStdout', gitStdout);
96
105
  await execute(`git add ${settings.docsPath}`);
97
106
  await execute(`git commit -m "📝 docs: Updated docs${settings.packageVersion !== '' ? ' for ' + settings.packageVersion : ''}"`);
98
- await execute(`git push -u origin ${stdout}`);
107
+ await execute(`git push -u origin ${gitStdout}`);
99
108
  }
100
109
 
101
110
  async function revertChanges(settings) {
@@ -164,8 +173,8 @@ async function init() {
164
173
  settings["packageVersion"] = await openingPackageJson(settings);
165
174
  settings["newVersion"] = await getNewVersion();
166
175
 
167
- await cleaningProject(settings);
168
- await buildingBundle(settings);
176
+ // await cleaningProject(settings);
177
+ // await buildingBundle(settings);
169
178
  await startPublishingVersion(settings);
170
179
  await startGeneratingDocs(settings);
171
180
  console.info('Finished Publishing');
@@ -174,6 +183,7 @@ async function init() {
174
183
  await revertChanges(settings);
175
184
  } finally {
176
185
  console.log('Execution finished');
186
+ exit();
177
187
  }
178
188
  }
179
189