@yuw-cli-dev/utils 1.0.38 → 1.0.39
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.
- package/lib/index.js +31 -4
- package/package.json +5 -2
package/lib/index.js
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
function isObject(o) {
|
|
4
|
-
return Object.prototype.toString.call(o) ===
|
|
4
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function normalizePath(path) {
|
|
8
|
-
return path.replace(/[\\/]+/g,
|
|
8
|
+
return path.replace(/[\\/]+/g, '/');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
function spinnerStart(msg, spinnerString = '|/-\\') {
|
|
12
|
+
const Spinner = require('cli-spinner').Spinner;
|
|
13
|
+
const spinner = new Spinner(msg + ' %s');
|
|
14
|
+
spinner.setSpinnerString(spinnerString);
|
|
15
|
+
spinner.start();
|
|
16
|
+
return spinner;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function exec(command, args, options) {
|
|
20
|
+
const win32 = process.platform === 'win32';
|
|
21
|
+
const cmd = win32 ? 'cmd' : command;
|
|
22
|
+
const cmdArgs = win32 ? ['/c'].concat(command, args) : args;
|
|
23
|
+
return require('child_process').spawn(cmd, cmdArgs, options || {});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function execSync(command, args, options) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const p = exec(command, args, options);
|
|
29
|
+
p.on('error', e => {
|
|
30
|
+
reject(e);
|
|
31
|
+
});
|
|
32
|
+
p.on('exit', c => {
|
|
33
|
+
resolve(c);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = { isObject, normalizePath, spinnerStart, exec, execSync };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuw-cli-dev/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "yuwei <yuwei@huya.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "7bcace542ccccc47f518b0537cbb0cce93229adf",
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"cli-spinner": "^0.2.10"
|
|
22
25
|
}
|
|
23
26
|
}
|