@abtnode/util 1.16.29-beta-cbfd116d → 1.16.29-next-680cf137

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/lib/run-script.js +14 -17
  2. package/package.json +6 -6
package/lib/run-script.js CHANGED
@@ -83,6 +83,7 @@ const runScript = (script, label, options = {}) => {
83
83
  const promise = new Promise((resolve, reject) => {
84
84
  process.stdout.setMaxListeners(0);
85
85
  process.stderr.setMaxListeners(0);
86
+
86
87
  let [command, ...args] = script.split(' ');
87
88
  if (fs.existsSync(command) === false) {
88
89
  command = which.sync(command);
@@ -133,8 +134,20 @@ const runScript = (script, label, options = {}) => {
133
134
 
134
135
  let hasUnhandledRejection = false;
135
136
  const errorMessages = [];
137
+ child.stderr.on('data', (err) => {
138
+ errorMessages.push(err);
139
+ if (err.includes('UnhandledPromiseRejectionWarning')) {
140
+ hasUnhandledRejection = true;
141
+ }
142
+ });
136
143
 
137
- const handleExit = (code, signal) => {
144
+ child.on('error', (err) => {
145
+ console.error(err);
146
+ errorMessages.push(err.message);
147
+ return reject(new Error(errorMessages.join('\r\n')));
148
+ });
149
+
150
+ child.on('close', (code, signal) => {
138
151
  if (signal) {
139
152
  if (Date.now() - now > timeout) {
140
153
  return reject(new Error(`Process timeout after ${timeout / 1000} seconds`));
@@ -149,23 +162,7 @@ const runScript = (script, label, options = {}) => {
149
162
  }
150
163
 
151
164
  return resolve({ code, script });
152
- };
153
-
154
- child.stderr.on('data', (err) => {
155
- errorMessages.push(err);
156
- if (err.includes('UnhandledPromiseRejectionWarning')) {
157
- hasUnhandledRejection = true;
158
- }
159
165
  });
160
-
161
- child.on('error', (err) => {
162
- console.error(err);
163
- errorMessages.push(err.message);
164
- return reject(new Error(errorMessages.join('\r\n')));
165
- });
166
-
167
- child.on('close', handleExit);
168
- child.on('exit', handleExit);
169
166
  });
170
167
 
171
168
  promise.abort = cleanup;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.29-beta-cbfd116d",
6
+ "version": "1.16.29-next-680cf137",
7
7
  "description": "ArcBlock's JavaScript utility",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,11 +18,11 @@
18
18
  "author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
19
19
  "license": "Apache-2.0",
20
20
  "dependencies": {
21
- "@abtnode/constant": "1.16.29-beta-cbfd116d",
22
- "@abtnode/logger": "1.16.29-beta-cbfd116d",
21
+ "@abtnode/constant": "1.16.29-next-680cf137",
22
+ "@abtnode/logger": "1.16.29-next-680cf137",
23
23
  "@arcblock/pm2": "^5.4.0",
24
- "@blocklet/constant": "1.16.29-beta-cbfd116d",
25
- "@blocklet/meta": "1.16.29-beta-cbfd116d",
24
+ "@blocklet/constant": "1.16.29-next-680cf137",
25
+ "@blocklet/meta": "1.16.29-next-680cf137",
26
26
  "@ocap/client": "1.18.126",
27
27
  "@ocap/mcrypto": "1.18.126",
28
28
  "@ocap/util": "1.18.126",
@@ -79,5 +79,5 @@
79
79
  "fs-extra": "^11.2.0",
80
80
  "jest": "^29.7.0"
81
81
  },
82
- "gitHead": "e9bdb7af77f2d126e40195c67972b07fe683adf9"
82
+ "gitHead": "17b7e7c5e43c497980d4fe6b5bb20609328041bd"
83
83
  }