binhend 1.5.15 → 1.5.16

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.
@@ -11,8 +11,10 @@ module.exports = (args) => {
11
11
 
12
12
  npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
13
13
 
14
- runCommand(npm, ['install'], options)
15
- .then(() => {
16
- runCommand('node', ['test.js'].concat(args), options)
14
+ console.log(`[BINHEND][CLI] Setup testing environment: ${testFolder}`);
15
+ runCommand(npm, ['install'], options).done(() => {
16
+
17
+ console.log(`[BINHEND][CLI] Start testing: ${testFolder}`);
18
+ runCommand('node', ['test.js'].concat(args), options);
17
19
  });
18
20
  };
@@ -5,27 +5,28 @@ function printOut(data) {
5
5
  process.stdout.write(`${data}`);
6
6
  }
7
7
 
8
- function printErr(ref, error) {
9
- process.stdout.write(`[BINHEND][CLI] Error executing command: ${ref.fullCommand}\n`);
10
- process.stdout.write(`${error}`);
11
- ref.reject(error);
8
+ function printError(error) {
9
+ process.stderr.write(`${error}`);
12
10
  }
13
11
 
14
12
  module.exports = function() {
15
- return new Promise((resolve, reject) => {
16
- const command = arguments[0], args = arguments[1] || [],
17
- fullCommand = `${command} ${args.join(' ')}`,
18
-
19
- printError = printErr.bind(null, { fullCommand, reject }),
20
-
21
- child = spawn.apply(null, arguments);
22
-
23
- child.stdout.on('data', printOut);
24
-
25
- child.stderr.on('data', printError);
26
-
27
- child.on('error', printError);
28
-
29
- child.on('close', resolve);
13
+ var ref = {}, onClosed = () => {},
14
+
15
+ child = spawn.apply(null, arguments);
16
+
17
+ child.stdout.on('data', printOut);
18
+
19
+ child.stderr.on('data', printError);
20
+
21
+ child.on('error', printError);
22
+
23
+ child.on('close', (code) => {
24
+ onClosed(code);
30
25
  });
26
+
27
+ ref.done = (callback) => {
28
+ onClosed = callback instanceof Function ? callback : () => {};
29
+ };
30
+
31
+ return ref;
31
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "binhend",
3
- "version": "1.5.15",
3
+ "version": "1.5.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "Nguyen Duc Binh",