@makano/rew 1.1.81 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/coffeescript/browser.js +144 -139
- package/lib/coffeescript/cake.js +132 -133
- package/lib/coffeescript/coffeescript.js +437 -381
- package/lib/coffeescript/command.js +806 -724
- package/lib/coffeescript/grammar.js +1908 -2474
- package/lib/coffeescript/helpers.js +509 -473
- package/lib/coffeescript/index.js +228 -215
- package/lib/coffeescript/lexer.js +2282 -1909
- package/lib/coffeescript/nodes.js +9782 -9202
- package/lib/coffeescript/optparse.js +255 -227
- package/lib/coffeescript/parser.js +20305 -1265
- package/lib/coffeescript/register.js +107 -87
- package/lib/coffeescript/repl.js +307 -284
- package/lib/coffeescript/rewriter.js +1389 -1079
- package/lib/coffeescript/scope.js +176 -172
- package/lib/coffeescript/sourcemap.js +242 -227
- package/lib/rew/cli/cli.js +312 -239
- package/lib/rew/cli/log.js +27 -27
- package/lib/rew/cli/run.js +8 -8
- package/lib/rew/cli/utils.js +368 -199
- package/lib/rew/const/config_path.js +2 -2
- package/lib/rew/const/default.js +38 -53
- package/lib/rew/const/files.js +11 -14
- package/lib/rew/const/opt.js +6 -6
- package/lib/rew/css/theme.css +1 -1
- package/lib/rew/functions/core.js +55 -55
- package/lib/rew/functions/curl.js +23 -0
- package/lib/rew/functions/emitter.js +52 -55
- package/lib/rew/functions/exec.js +25 -25
- package/lib/rew/functions/export.js +17 -17
- package/lib/rew/functions/fs.js +57 -59
- package/lib/rew/functions/future.js +29 -21
- package/lib/rew/functions/id.js +8 -9
- package/lib/rew/functions/import.js +106 -122
- package/lib/rew/functions/map.js +10 -10
- package/lib/rew/functions/match.js +35 -42
- package/lib/rew/functions/path.js +8 -8
- package/lib/rew/functions/require.js +32 -36
- package/lib/rew/functions/sleep.js +2 -2
- package/lib/rew/functions/stdout.js +18 -18
- package/lib/rew/functions/types.js +82 -106
- package/lib/rew/html/ui.html +12 -12
- package/lib/rew/html/ui.js +196 -201
- package/lib/rew/main.js +14 -14
- package/lib/rew/misc/bin.js +37 -0
- package/lib/rew/misc/findAppInfo.js +13 -13
- package/lib/rew/misc/findAppPath.js +15 -15
- package/lib/rew/misc/req.js +7 -0
- package/lib/rew/misc/seededid.js +8 -8
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +237 -209
- package/lib/rew/modules/fs.js +10 -10
- package/lib/rew/modules/runtime.js +17 -21
- package/lib/rew/modules/yaml.js +27 -30
- package/lib/rew/pkgs/conf.js +82 -92
- package/lib/rew/pkgs/data.js +10 -10
- package/lib/rew/pkgs/date.js +27 -27
- package/lib/rew/pkgs/env.js +5 -5
- package/lib/rew/pkgs/modules/data/bintree.js +51 -51
- package/lib/rew/pkgs/modules/data/doublylinked.js +84 -84
- package/lib/rew/pkgs/modules/data/linkedList.js +72 -72
- package/lib/rew/pkgs/modules/data/queue.js +18 -18
- package/lib/rew/pkgs/modules/data/stack.js +18 -18
- package/lib/rew/pkgs/modules/threads/worker.js +36 -36
- package/lib/rew/pkgs/modules/ui/classes.js +181 -184
- package/lib/rew/pkgs/pkgs.js +9 -9
- package/lib/rew/pkgs/rune.js +373 -410
- package/lib/rew/pkgs/threads.js +62 -66
- package/lib/rew/pkgs/ui.js +148 -160
- package/lib/rew/qrew/compile.js +12 -0
- package/package.json +4 -3
@@ -1,23 +1,31 @@
|
|
1
|
-
const emitter = require(
|
1
|
+
const emitter = require('./emitter');
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
function future(callback, timeout = 0, defData = null) {
|
4
|
+
const listener = emitter();
|
5
|
+
const promise = new Promise((resolve, reject) => {
|
6
|
+
listener.on('resolve', (data) => {
|
7
|
+
resolve(data);
|
8
|
+
});
|
9
|
+
listener.on('reject', (data) => {
|
10
|
+
reject(data);
|
11
|
+
});
|
12
|
+
callback(resolve, reject);
|
13
|
+
if (timeout) setTimeout(() => resolve(defData), timeout);
|
14
|
+
});
|
15
|
+
return {
|
16
|
+
pipe: (callback) => promise.then(callback),
|
17
|
+
last: (callback) => promise.finally(callback),
|
18
|
+
catch: (callback) => promise.catch(callback),
|
19
|
+
resolve: (data) => listener.emit('resolve', data),
|
20
|
+
reject: (data) => listener.emit('reject', data),
|
21
|
+
wait: async () => await promise,
|
22
|
+
};
|
23
23
|
};
|
24
|
+
|
25
|
+
future.promise = (promse, timeout = 0, defData = null) => {
|
26
|
+
return future((resolve, reject) => {
|
27
|
+
promse.then(resolve).catch(reject);
|
28
|
+
}, timeout, defData);
|
29
|
+
}
|
30
|
+
|
31
|
+
module.exports = future;
|
package/lib/rew/functions/id.js
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module.exports.generateRandomID = function generateRandomID(length = 12) {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
let randomID = "";
|
2
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
3
|
+
const charactersLength = characters.length;
|
4
|
+
let randomID = '';
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
for (let i = 0; i < length; i++) {
|
7
|
+
const randomIndex = Math.floor(Math.random() * charactersLength);
|
8
|
+
randomID += characters.charAt(randomIndex);
|
9
|
+
}
|
11
10
|
|
12
|
-
|
11
|
+
return randomID;
|
13
12
|
};
|
@@ -1,142 +1,126 @@
|
|
1
|
-
const path = require(
|
2
|
-
const { getFile, file } = require(
|
3
|
-
const { importYaml } = require(
|
4
|
-
const { findPackage, getPackage } = require(
|
5
|
-
const { existsSync, readFileSync } = require(
|
6
|
-
const conf = require(
|
7
|
-
const jsYaml = require(
|
8
|
-
const { execOptions } = require(
|
1
|
+
const path = require('path');
|
2
|
+
const { getFile, file } = require('../modules/fs');
|
3
|
+
const { importYaml } = require('../modules/yaml');
|
4
|
+
const { findPackage, getPackage } = require('../pkgs/pkgs');
|
5
|
+
const { existsSync, readFileSync } = require('fs');
|
6
|
+
const conf = require('../pkgs/conf');
|
7
|
+
const jsYaml = require('js-yaml');
|
8
|
+
const { execOptions } = require('../const/opt');
|
9
9
|
|
10
10
|
const cachedFiles = [];
|
11
11
|
|
12
12
|
const lookUpInOtherApps = (fullPath) => {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
const con = conf({});
|
14
|
+
const name = fullPath.indexOf('/') ? fullPath.split('/')[0] : fullPath;
|
15
|
+
let dpath = fullPath.indexOf('/') ? fullPath.split('/')[1] : '';
|
16
|
+
let ppath = path.join(con.CONFIG_PATH, name, 'app');
|
17
|
+
const config = jsYaml.load(readFileSync(path.join(ppath, 'app.yaml'), 'utf-8'));
|
18
|
+
if (!existsSync(ppath)) return null;
|
19
|
+
if (!dpath) {
|
20
|
+
dpath = config.entry;
|
21
|
+
}
|
22
|
+
if(config.private == true) return null;
|
23
|
+
const pepath = path.join(ppath, dpath);
|
24
|
+
if(Array.isArray(config.private)){
|
25
|
+
if(config.private.find(f => pepath == path.join(ppath, f))) return null;
|
26
|
+
}
|
27
|
+
if (existsSync(pepath)) return pepath;
|
28
|
+
else return null;
|
26
29
|
};
|
27
30
|
|
28
31
|
module.exports.imp = function (runPath, context) {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
return function (filename, options = {}) {
|
33
|
+
if (!options) options = {};
|
34
|
+
let type = options.type || 'coffee';
|
35
|
+
let exports,
|
36
|
+
ispkg = findPackage(filename);
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
if (filename.startsWith('@') && context.app) {
|
39
|
+
filename = filename.replace('@', context.app.path);
|
40
|
+
}
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
filename,
|
42
|
-
);
|
42
|
+
let filepath = path.resolve(path.dirname(context.module.filepath), filename);
|
43
|
+
if(path.extname(filepath) == '.qrew') options.qrew = true;
|
43
44
|
|
44
|
-
|
45
|
+
// console.log(typeof runPath);
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
const lookUp = () => {
|
48
|
+
const otherPath = lookUpInOtherApps(filename);
|
49
|
+
if (!otherPath) throw new Error('Module "' + filename + '" not found');
|
50
|
+
else filepath = otherPath;
|
51
|
+
};
|
51
52
|
|
52
|
-
|
53
|
+
const foundCache = cachedFiles.find((f) => f.filepath == filepath);
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
if (!ispkg && foundCache) {
|
56
|
+
exports = foundCache.exports;
|
57
|
+
}
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
for (let i in resolve.options) options[i] = resolve.options[i];
|
73
|
-
}
|
74
|
-
} else lookUp();
|
75
|
-
} else lookUp();
|
76
|
-
}
|
59
|
+
if (!ispkg && !existsSync(filepath)) {
|
60
|
+
if (Array.isArray(execOptions.resolveExtensions) && execOptions.resolveExtensions.length) {
|
61
|
+
const resolve = execOptions.resolveExtensions.find((ext) =>
|
62
|
+
typeof ext == 'string' ? existsSync(filepath + ext) : existsSync(filepath + (ext.ext || '')),
|
63
|
+
);
|
64
|
+
if (resolve) {
|
65
|
+
filepath += typeof resolve == 'string' ? resolve : resolve.ext;
|
66
|
+
if (typeof resolve == 'object' && resolve.options) {
|
67
|
+
if (resolve.options.type) type = resolve.options.type;
|
68
|
+
for (let i in resolve.options) options[i] = resolve.options[i];
|
69
|
+
}
|
70
|
+
} else lookUp();
|
71
|
+
} else lookUp();
|
72
|
+
}
|
77
73
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
: "parent"
|
94
|
-
: options.as == "parent"
|
95
|
-
? "parent"
|
96
|
-
: "child",
|
97
|
-
fromMain: context.module.main,
|
98
|
-
},
|
99
|
-
execOptions.sharedContext == false
|
100
|
-
? {}
|
101
|
-
: options.context && options.context == "new"
|
102
|
-
? {}
|
103
|
-
: context,
|
104
|
-
).context.module.exports;
|
74
|
+
const exec = (coptions = {}) =>
|
75
|
+
runPath(
|
76
|
+
filepath,
|
77
|
+
{
|
78
|
+
import: options,
|
79
|
+
main: false,
|
80
|
+
useContext: execOptions.sharedContext == false ? false : !(options.context && options.context == 'new'),
|
81
|
+
...coptions,
|
82
|
+
as: options.as == 'main' ? (context.module.main ? 'main' : 'parent') : options.as == 'parent' ? 'parent' : 'child',
|
83
|
+
fromMain: context.module.main,
|
84
|
+
qrew: options.qrew,
|
85
|
+
package: context.app ? context.app.config.package : path.basename(filepath)
|
86
|
+
},
|
87
|
+
execOptions.sharedContext == false ? {} : options.context && options.context == 'new' ? {} : context,
|
88
|
+
).context.module.exports;
|
105
89
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
90
|
+
if (ispkg) {
|
91
|
+
const pkg = getPackage(filename)(context);
|
92
|
+
exports = pkg._onImport ? pkg._onImport() : pkg;
|
93
|
+
} else if (foundCache) {
|
94
|
+
} else if (type == 'coffee') {
|
95
|
+
exports = exec({});
|
96
|
+
} else if (type == 'js') {
|
97
|
+
exports = exec({ compile: false });
|
98
|
+
} else if (type == 'yaml' || type == 'json' || type == 'text') {
|
99
|
+
const f = getFile(filepath);
|
100
|
+
if (type == 'yaml') {
|
101
|
+
exports = importYaml(f.path, f);
|
102
|
+
} else if (type == 'json') {
|
103
|
+
try {
|
104
|
+
exports = JSON.parse(f.content);
|
105
|
+
} catch (e) {
|
106
|
+
exports = {};
|
107
|
+
}
|
108
|
+
} else {
|
109
|
+
exports = f.content;
|
110
|
+
}
|
111
|
+
}
|
128
112
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
113
|
+
if (options.save && (type == 'js' || type == 'coffee')) {
|
114
|
+
if (typeof options.save == 'string') context[options.save] = exports[i];
|
115
|
+
else
|
116
|
+
for (let i in exports) {
|
117
|
+
context[i] = exports[i];
|
118
|
+
}
|
119
|
+
}
|
136
120
|
|
137
|
-
|
138
|
-
|
121
|
+
if (!ispkg) context.module.imports.push(filepath);
|
122
|
+
if (!ispkg) cachedFiles.push({ filepath, exports });
|
139
123
|
|
140
|
-
|
141
|
-
|
124
|
+
return exports;
|
125
|
+
};
|
142
126
|
};
|
package/lib/rew/functions/map.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module.exports.map = function map(...args) {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
if (args.length % 2 !== 0) {
|
3
|
+
throw new Error('Arguments must be in key-value pairs');
|
4
|
+
}
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
const result = new Map();
|
7
|
+
for (let i = 0; i < args.length; i += 2) {
|
8
|
+
const key = args[i];
|
9
|
+
const value = args[i + 1];
|
10
|
+
result.set(key, value);
|
11
|
+
}
|
12
12
|
|
13
|
-
|
13
|
+
return result;
|
14
14
|
};
|
@@ -1,50 +1,43 @@
|
|
1
|
-
const SerializableData = [
|
1
|
+
const SerializableData = ['string', 'number', 'boolean'];
|
2
2
|
|
3
|
-
const isRegExp = (obj) =>
|
4
|
-
Object.prototype.toString.call(obj) === "[object RegExp]";
|
3
|
+
const isRegExp = (obj) => Object.prototype.toString.call(obj) === '[object RegExp]';
|
5
4
|
|
6
5
|
module.exports.match = function match(value, templates, props) {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
6
|
+
const matchProps = (pattern, value) => {
|
7
|
+
if (!props) return false;
|
8
|
+
if (typeof props === 'object') {
|
9
|
+
let t = true;
|
10
|
+
for (let i in props) {
|
11
|
+
t = t && pattern[i] == value[i];
|
12
|
+
if (!t) break;
|
13
|
+
}
|
14
|
+
return t;
|
15
|
+
} else if (typeof props === 'function') {
|
16
|
+
return props(pattern, value);
|
17
|
+
} else {
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
};
|
22
21
|
|
23
|
-
|
22
|
+
const matchRegex = (pattern, value) => pattern.test(value);
|
24
23
|
|
25
|
-
|
26
|
-
templates instanceof Map
|
27
|
-
? templates.entries()
|
28
|
-
: Array.isArray(templates)
|
29
|
-
? templates
|
30
|
-
: Object.entries(templates);
|
24
|
+
const entries = templates instanceof Map ? templates.entries() : Array.isArray(templates) ? templates : Object.entries(templates);
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
26
|
+
for (const [pattern, callback] of entries) {
|
27
|
+
if (
|
28
|
+
isRegExp(pattern)
|
29
|
+
? matchRegex(pattern, value)
|
30
|
+
: SerializableData.includes(typeof value)
|
31
|
+
? pattern == value
|
32
|
+
: isRegExp(pattern)
|
33
|
+
? matchRegex(pattern, value)
|
34
|
+
: typeof pattern === 'function'
|
35
|
+
? value instanceof pattern || value?.__proto__?.['@instance'] === pattern
|
36
|
+
: matchProps(pattern, value)
|
37
|
+
) {
|
38
|
+
return callback(...(isRegExp(pattern) ? pattern.exec(value) : [value]));
|
39
|
+
}
|
40
|
+
}
|
48
41
|
|
49
|
-
|
42
|
+
return null;
|
50
43
|
};
|
@@ -1,13 +1,13 @@
|
|
1
|
-
const path = require(
|
1
|
+
const path = require('path');
|
2
2
|
|
3
3
|
module.exports = (currentFile) => {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
const e = {};
|
5
|
+
e.basename = (pathname, suffix) => path.basename(pathname, suffix);
|
6
|
+
e.dirname = (pathname) => path.dirname(pathname);
|
7
|
+
e.extname = (pathname) => path.extname(pathname);
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
e.pjoin = (...paths) => path.join(...paths);
|
10
|
+
e.presolve = (...paths) => path.resolve(...paths);
|
11
11
|
|
12
|
-
|
12
|
+
return e;
|
13
13
|
};
|
@@ -1,44 +1,40 @@
|
|
1
|
-
const fs = require(
|
2
|
-
const path = require(
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
3
|
|
4
4
|
module.exports.customRequire = function customRequire(modulePath, filePath) {
|
5
|
-
|
6
|
-
|
5
|
+
const resolvedPath = resolveModulePath(modulePath, filePath);
|
6
|
+
return require(resolvedPath);
|
7
7
|
};
|
8
8
|
|
9
9
|
function resolveModulePath(modulePath, filePath) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
path.isAbsolute(modulePath)
|
14
|
-
) {
|
15
|
-
return path.resolve(modulePath);
|
16
|
-
}
|
10
|
+
if (modulePath.startsWith('./') || modulePath.startsWith('../') || path.isAbsolute(modulePath)) {
|
11
|
+
return path.resolve(modulePath);
|
12
|
+
}
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
14
|
+
const paths = module.constructor._nodeModulePaths(path.dirname(filePath));
|
15
|
+
for (const basePath of paths) {
|
16
|
+
const fullPath = path.join(basePath, modulePath);
|
17
|
+
if (fs.existsSync(fullPath + '.js')) {
|
18
|
+
return fullPath + '.js';
|
19
|
+
}
|
20
|
+
if (fs.existsSync(fullPath + '.json')) {
|
21
|
+
return fullPath + '.json';
|
22
|
+
}
|
23
|
+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
|
24
|
+
const packageJsonPath = path.join(fullPath, 'package.json');
|
25
|
+
if (fs.existsSync(packageJsonPath)) {
|
26
|
+
const main = require(packageJsonPath).main || 'index.js';
|
27
|
+
const mainPath = path.join(fullPath, main);
|
28
|
+
if (fs.existsSync(mainPath)) {
|
29
|
+
return mainPath;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
const indexPath = path.join(fullPath, 'index.js');
|
33
|
+
if (fs.existsSync(indexPath)) {
|
34
|
+
return indexPath;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
42
38
|
|
43
|
-
|
39
|
+
throw new Error(`Cannot find module '${modulePath}'`);
|
44
40
|
}
|
@@ -1,30 +1,30 @@
|
|
1
|
-
const { execSync, spawnSync } = require(
|
2
|
-
const fs = require(
|
1
|
+
const { execSync, spawnSync } = require('child_process');
|
2
|
+
const fs = require('fs');
|
3
3
|
|
4
4
|
const print = (module.exports.print = function print(...arguments) {
|
5
|
-
|
5
|
+
return console.log(...arguments);
|
6
6
|
});
|
7
7
|
|
8
8
|
print.stdout = process.stdout;
|
9
9
|
print.stdin = process.stdin;
|
10
10
|
|
11
11
|
module.exports.input = function input(prompt) {
|
12
|
-
|
12
|
+
process.stdout.write(prompt);
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
let cmd;
|
15
|
+
let args;
|
16
|
+
if ('null' == 'win32') {
|
17
|
+
cmd = 'cmd';
|
18
|
+
args = ['/V:ON', '/C', 'set /p response= && echo !response!'];
|
19
|
+
} else {
|
20
|
+
cmd = 'bash';
|
21
|
+
args = ['-c', 'read response; echo "$response"'];
|
22
|
+
}
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
let opts = {
|
25
|
+
stdio: ['inherit', 'pipe'],
|
26
|
+
shell: false,
|
27
|
+
};
|
28
28
|
|
29
|
-
|
29
|
+
return spawnSync(cmd, args, opts).stdout.toString().trim();
|
30
30
|
};
|