node-megabalabolka 1.0.1 → 1.0.2

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/index.js +46 -29
  2. package/package.json +23 -23
package/index.js CHANGED
@@ -1,70 +1,87 @@
1
1
  /**
2
2
  * Written By MegaT
3
3
  * 2022
4
+ * Patch written in 2026 to fix all of the glaring issues oh my lord
4
5
  */
5
6
 
6
- const { exec } = require('child_process');
7
+ const { spawn } = require('child_process');
7
8
 
8
9
  function generate(options) {
9
10
  return new Promise(function (resolve, reject) {
10
- var prompt;
11
+ let prompt = [];
11
12
  var list = false;
13
+ var enableErrorLogs = true;
14
+ if (options.enableErrorLogs == false) {
15
+ enableErrorLogs = false;
16
+ }
12
17
  if (options.list == true) {
13
- prompt = `balcon -l`
18
+ prompt.push(`-l`)
14
19
  list = true;
15
20
  }
16
21
  else {
17
- prompt = `balcon`;
18
22
  if (options.voice) {
19
- prompt += ` -n "${options.voice}" `
23
+ prompt.push(`-n`)
24
+ prompt.push(`${options.voice}`)
20
25
  }
21
26
  if (options.text) {
22
- prompt += `-t "${options.text.replace(/["]+/g, '')}" `
27
+ prompt.push(`-t`)
28
+ prompt.push(`${options.text.replace(/["]+/g, '')}`)
23
29
  }
24
30
  if (options.speed) {
25
- prompt += `-s "${options.speed}" `
31
+ prompt.push(`-s`)
32
+ prompt.push(`${options.speed}`)
26
33
  }
27
34
  if (options.pitch) {
28
- prompt += `-p "${options.pitch}" `
35
+ prompt.push(`-p`)
36
+ prompt.push(`${options.pitch}`)
29
37
  }
30
38
  if (options.volume) {
31
- prompt += `-v "${options.volume}" `
39
+ prompt.push(`-v`)
40
+ prompt.push(`${options.volume}`)
32
41
  }
33
42
  if (!options.writeToBuffer) {
34
43
  if (options.file) {
35
- prompt += `-w "${options.file}" `
44
+ prompt.push(`-w`)
45
+ prompt.push(`${options.file}`)
36
46
  }
37
47
  } else {
38
- prompt += `-o`
48
+ prompt.push(`-o`)
39
49
  if (options.ignoreLength)
40
- prompt += ` -il`
50
+ prompt.push(`-il`)
41
51
  if (options.encoding) {
42
- prompt += ` --encoding ${options.encoding}`
52
+ prompt.push(`--encoding`)
53
+ prompt.push(`${options.encoding}`)
43
54
  }
44
55
  }
45
56
  if (options.raw) {
46
- prompt += ` --raw`
57
+ prompt.push(`--raw`)
47
58
  }
48
59
  }
49
- const ls = exec(prompt, function (error, stdout, stderr) {
50
- if (error) {
51
- console.log('STDERR: ' + stderr);
52
- console.error(error.stack);
53
- console.error('Error code: ' + error.code);
54
- console.error('Signal received: ' + error.signal);
55
- reject(stderr);
56
- }
57
- if (options.warnings) {
58
- if (stderr)
59
- console.log('Warning: ' + stderr);
60
- }
61
- if (list = true) {
62
- resolve(stdout);
60
+ const ls = spawn(`balcon`, prompt);
61
+ let buffers = [];
62
+ ls.stdout.on("data", (b) => buffers.push(b));
63
+
64
+ ls.stderr.on('data', function (data) {
65
+ if (enableErrorLogs) {
66
+ console.error('stderr: ' + data.toString());
63
67
  }
64
68
  });
65
69
 
66
- ls.on('exit', function (code) {
70
+ ls.stdout.on("end", async () => {
71
+ if (list == false) {
72
+ let res = Buffer.concat(buffers)
73
+ return resolve(res);
74
+ } else {
75
+ let l = Buffer.concat(buffers).toString()
76
+ //let l = Buffer.concat(buffers).toString().split("\r\n");
77
+ //l.forEach((e, i)=> l[i] = e.trim());
78
+ return resolve(l)
79
+ }
67
80
  })
81
+
82
+ ls.on('exit', function (code) {
83
+
84
+ });
68
85
  })
69
86
  }
70
87
 
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "name": "node-megabalabolka",
3
- "version": "1.0.1",
4
- "description": "This package communicates with balcon and gives the information back to nodejs",
5
- "main": "index.js",
6
- "scripts": {
7
- "start": "node index.js"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/MegaTeam89/node-megabalabolka.git"
12
- },
13
- "keywords": [
14
- "balabolka",
15
- "balcon"
16
- ],
17
- "author": "MegaT",
18
- "license": "GPL-3.0",
19
- "bugs": {
20
- "url": "https://github.com/MegaTeam89/node-megabalabolka/issues"
21
- },
22
- "homepage": "https://github.com/MegaTeam89/node-megabalabolka#readme"
23
- }
1
+ {
2
+ "name": "node-megabalabolka",
3
+ "version": "1.0.2",
4
+ "description": "This package communicates with balcon and gives the information back to nodejs",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "node index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/MegaTeam89/node-megabalabolka.git"
12
+ },
13
+ "keywords": [
14
+ "balabolka",
15
+ "balcon"
16
+ ],
17
+ "author": "MegaT",
18
+ "license": "GPL-3.0",
19
+ "bugs": {
20
+ "url": "https://github.com/MegaTeam89/node-megabalabolka/issues"
21
+ },
22
+ "homepage": "https://github.com/MegaTeam89/node-megabalabolka#readme"
23
+ }