@makano/rew 1.1.72 → 1.1.81
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/build.sh +3 -1
- package/lib/rew/cli/cli.js +189 -144
- package/lib/rew/cli/log.js +18 -19
- package/lib/rew/cli/run.js +7 -9
- package/lib/rew/cli/utils.js +109 -95
- package/lib/rew/const/config_path.js +4 -0
- package/lib/rew/const/default.js +21 -3
- package/lib/rew/const/files.js +11 -8
- package/lib/rew/const/opt.js +6 -6
- package/lib/rew/css/theme.css +1 -1
- package/lib/rew/functions/core.js +7 -9
- package/lib/rew/functions/emitter.js +2 -2
- package/lib/rew/functions/exec.js +19 -15
- package/lib/rew/functions/export.js +4 -6
- package/lib/rew/functions/fs.js +21 -18
- package/lib/rew/functions/future.js +1 -1
- package/lib/rew/functions/import.js +55 -25
- package/lib/rew/functions/map.js +2 -5
- package/lib/rew/functions/match.js +21 -5
- package/lib/rew/functions/path.js +2 -2
- package/lib/rew/functions/require.js +16 -13
- package/lib/rew/functions/stdout.js +11 -11
- package/lib/rew/functions/types.js +67 -42
- package/lib/rew/html/ui.html +5 -6
- package/lib/rew/html/ui.js +100 -58
- package/lib/rew/main.js +3 -3
- package/lib/rew/misc/findAppInfo.js +16 -0
- package/lib/rew/misc/findAppPath.js +21 -0
- package/lib/rew/misc/seededid.js +13 -0
- package/lib/rew/models/struct.js +1 -1
- package/lib/rew/modules/compiler.js +90 -58
- package/lib/rew/modules/context.js +35 -22
- package/lib/rew/modules/runtime.js +1 -1
- package/lib/rew/pkgs/conf.js +50 -33
- package/lib/rew/pkgs/data.js +7 -2
- package/lib/rew/pkgs/date.js +8 -9
- package/lib/rew/pkgs/env.js +3 -5
- package/lib/rew/pkgs/modules/data/bintree.js +1 -1
- package/lib/rew/pkgs/modules/data/doublylinked.js +1 -1
- package/lib/rew/pkgs/modules/data/linkedList.js +1 -1
- package/lib/rew/pkgs/modules/data/queue.js +1 -2
- package/lib/rew/pkgs/modules/data/stack.js +1 -1
- package/lib/rew/pkgs/modules/threads/worker.js +31 -21
- package/lib/rew/pkgs/modules/ui/classes.js +68 -61
- package/lib/rew/pkgs/pkgs.js +5 -6
- package/lib/rew/pkgs/rune.js +437 -0
- package/lib/rew/pkgs/threads.js +30 -22
- package/lib/rew/pkgs/ui.js +68 -44
- package/meson.build +1 -1
- package/package.json +8 -2
package/lib/rew/cli/utils.js
CHANGED
@@ -1,76 +1,82 @@
|
|
1
|
-
const path = require(
|
2
|
-
const fs = require(
|
3
|
-
const conf = require(
|
4
|
-
const jsYaml = require(
|
5
|
-
const readline = require(
|
6
|
-
const { log, logget } = require(
|
7
|
-
const { execSync, exec } = require(
|
8
|
-
const { run } = require(
|
9
|
-
const { generateRandomID } = require(
|
1
|
+
const path = require("path");
|
2
|
+
const fs = require("fs");
|
3
|
+
const conf = require("../pkgs/conf");
|
4
|
+
const jsYaml = require("js-yaml");
|
5
|
+
const readline = require("readline");
|
6
|
+
const { log, logget } = require("./log");
|
7
|
+
const { execSync, exec } = require("child_process");
|
8
|
+
const { run } = require("../main");
|
9
|
+
const { generateRandomID } = require("../functions/id");
|
10
10
|
|
11
|
-
const npm_package_name =
|
11
|
+
const npm_package_name = "@makano/rew";
|
12
12
|
|
13
13
|
module.exports = {
|
14
|
-
conf(command, fullPath, key, value){
|
14
|
+
conf(command, fullPath, key, value) {
|
15
15
|
const con = conf({});
|
16
|
-
if(command ==
|
17
|
-
if(!fullPath || fullPath ==
|
18
|
-
return fs.readdirSync(con.CONFIG_PATH).join(
|
16
|
+
if (command == "get") {
|
17
|
+
if (!fullPath || fullPath == "list") {
|
18
|
+
return fs.readdirSync(con.CONFIG_PATH).join("\n");
|
19
19
|
} else {
|
20
|
-
const name = fullPath.indexOf(
|
21
|
-
const dpath = fullPath.indexOf(
|
20
|
+
const name = fullPath.indexOf("/") ? fullPath.split("/")[0] : fullPath;
|
21
|
+
const dpath = fullPath.indexOf("/")
|
22
|
+
? fullPath.split("/").slice(1).join("/")
|
23
|
+
: "";
|
22
24
|
const root = con.create(name);
|
23
|
-
if(dpath){
|
25
|
+
if (dpath) {
|
24
26
|
const fp = path.join(root.root, dpath);
|
25
|
-
if(fs.existsSync(fp) && fs.statSync(fp).isDirectory()){
|
26
|
-
return fs.readdirSync(fp).join(
|
27
|
+
if (fs.existsSync(fp) && fs.statSync(fp).isDirectory()) {
|
28
|
+
return fs.readdirSync(fp).join("\n");
|
27
29
|
} else {
|
28
30
|
const o = con.create(name).optionCenter(dpath);
|
29
31
|
return key ? o.get(key) : o.getAll(true);
|
30
32
|
}
|
31
33
|
} else {
|
32
|
-
return fs.readdirSync(root.root).join(
|
34
|
+
return fs.readdirSync(root.root).join("\n");
|
33
35
|
}
|
34
36
|
}
|
35
37
|
} else {
|
36
|
-
const name = fullPath.indexOf(
|
37
|
-
const dpath = fullPath.indexOf(
|
38
|
-
if(name && key){
|
38
|
+
const name = fullPath.indexOf("/") ? fullPath.split("/")[0] : fullPath;
|
39
|
+
const dpath = fullPath.indexOf("/") ? fullPath.split("/")[1] : "";
|
40
|
+
if (name && key) {
|
39
41
|
const root = con.create(name);
|
40
42
|
const o = dpath ? root.optionCenter(dpath) : root;
|
41
|
-
if(command ==
|
42
|
-
if(value){
|
43
|
+
if (command == "set") {
|
44
|
+
if (value) {
|
43
45
|
o.set(key, value);
|
44
46
|
} else {
|
45
|
-
log(
|
47
|
+
log("Value not specified", ":end");
|
46
48
|
}
|
47
49
|
} else {
|
48
50
|
o.remove(key);
|
49
51
|
}
|
50
52
|
} else {
|
51
|
-
log(
|
52
|
-
!name ? 'Path not specified' : 'Key not specified', ':end'
|
53
|
-
);
|
53
|
+
log(!name ? "Path not specified" : "Key not specified", ":end");
|
54
54
|
}
|
55
55
|
}
|
56
56
|
},
|
57
57
|
createProject: (ppath) => {
|
58
58
|
const projectPath = path.join(process.cwd(), ppath);
|
59
|
-
log(
|
59
|
+
log("Crating at", ppath);
|
60
60
|
const rl = readline.createInterface({
|
61
61
|
input: process.stdin,
|
62
|
-
output: process.stdout
|
63
|
-
});
|
62
|
+
output: process.stdout,
|
63
|
+
});
|
64
64
|
const project = {};
|
65
65
|
const create = () => {
|
66
66
|
fs.mkdirSync(projectPath, { recursive: true });
|
67
|
-
const confPath = path.join(projectPath,
|
68
|
-
const entryFile = path.join(projectPath,
|
69
|
-
fs.writeFileSync(
|
67
|
+
const confPath = path.join(projectPath, "app.yaml");
|
68
|
+
const entryFile = path.join(projectPath, "main.coffee");
|
69
|
+
fs.writeFileSync(
|
70
|
+
confPath,
|
71
|
+
jsYaml.dump({ package: project.package, entry: "main.coffee" }),
|
72
|
+
);
|
70
73
|
fs.writeFileSync(entryFile, `print("Hello World!")`);
|
71
|
-
if(project.git) {
|
72
|
-
fs.writeFileSync(
|
73
|
-
|
74
|
+
if (project.git) {
|
75
|
+
fs.writeFileSync(
|
76
|
+
path.join(projectPath, ".gitignore"),
|
77
|
+
`node_modules/\npackage-lock.json`,
|
78
|
+
);
|
79
|
+
execSync("cd " + projectPath + " && git init .");
|
74
80
|
}
|
75
81
|
// log('Installing '+npm_package_name);
|
76
82
|
// exec('cd '+projectPath+' && npm i '+npm_package_name, (err) => {
|
@@ -81,15 +87,16 @@ module.exports = {
|
|
81
87
|
// rl.close();
|
82
88
|
// }
|
83
89
|
// });
|
84
|
-
log(
|
90
|
+
log("Done.", ":end");
|
85
91
|
rl.close();
|
86
|
-
}
|
92
|
+
};
|
87
93
|
if (!fs.existsSync(projectPath)) {
|
88
|
-
rl.question(logget(
|
89
|
-
if(pkg.trim()) {
|
94
|
+
rl.question(logget("Package Name: "), (pkg) => {
|
95
|
+
if (pkg.trim()) {
|
90
96
|
project.package = pkg.trim();
|
91
|
-
rl.question(logget(
|
92
|
-
project.git =
|
97
|
+
rl.question(logget("Use git(y/N): "), (use_git) => {
|
98
|
+
project.git =
|
99
|
+
use_git.toLowerCase() == "y" || use_git.toLowerCase() == "yes";
|
93
100
|
create();
|
94
101
|
});
|
95
102
|
} else {
|
@@ -97,96 +104,103 @@ module.exports = {
|
|
97
104
|
}
|
98
105
|
});
|
99
106
|
} else {
|
100
|
-
log(`Project ${ppath} already exists at ${projectPath}`,
|
107
|
+
log(`Project ${ppath} already exists at ${projectPath}`, ":end");
|
101
108
|
rl.close();
|
102
109
|
}
|
103
110
|
},
|
104
|
-
runApp(pathOrPackage){
|
111
|
+
runApp(pathOrPackage) {
|
105
112
|
const apppath = path.resolve(process.cwd(), pathOrPackage);
|
106
|
-
const appConfpath = path.join(apppath,
|
113
|
+
const appConfpath = path.join(apppath, "app.yaml");
|
107
114
|
|
108
115
|
const runAppRoot = (root, confPath) => {
|
109
|
-
const c = jsYaml.load(fs.readFileSync(confPath, { encoding:
|
110
|
-
if(c.entry){
|
116
|
+
const c = jsYaml.load(fs.readFileSync(confPath, { encoding: "utf-8" }));
|
117
|
+
if (c.entry) {
|
111
118
|
const r = path.resolve(root, c.entry);
|
112
|
-
const mod_path = path.resolve(root,
|
113
|
-
const mod_path_lib = path.join(mod_path,
|
114
|
-
if(fs.existsSync(mod_path) && __dirname !== mod_path_lib){
|
115
|
-
const mod_path_utilsjs = path.join(mod_path_lib,
|
116
|
-
require(mod_path_utilsjs)
|
117
|
-
.run(r);
|
119
|
+
const mod_path = path.resolve(root, "snode_moduless/@makano/rew");
|
120
|
+
const mod_path_lib = path.join(mod_path, "lib/rew/cli");
|
121
|
+
if (fs.existsSync(mod_path) && __dirname !== mod_path_lib) {
|
122
|
+
const mod_path_utilsjs = path.join(mod_path_lib, "../main.js");
|
123
|
+
require(mod_path_utilsjs).run(r);
|
118
124
|
} else run(r);
|
119
125
|
}
|
120
|
-
}
|
126
|
+
};
|
121
127
|
|
122
|
-
if(fs.existsSync(apppath) && fs.existsSync(appConfpath)){
|
128
|
+
if (fs.existsSync(apppath) && fs.existsSync(appConfpath)) {
|
123
129
|
runAppRoot(apppath, appConfpath);
|
124
130
|
} else {
|
125
131
|
const con = conf({});
|
126
|
-
const apppath = path.resolve(con.CONFIG_PATH, pathOrPackage,
|
127
|
-
const appConfpath = path.join(apppath,
|
128
|
-
if(fs.existsSync(apppath) && fs.existsSync(appConfpath)){
|
132
|
+
const apppath = path.resolve(con.CONFIG_PATH, pathOrPackage, "app");
|
133
|
+
const appConfpath = path.join(apppath, "app.yaml");
|
134
|
+
if (fs.existsSync(apppath) && fs.existsSync(appConfpath)) {
|
129
135
|
runAppRoot(apppath, appConfpath);
|
130
136
|
}
|
131
137
|
}
|
132
138
|
},
|
133
|
-
installApp(pathname, rmidir, rmidiri){
|
134
|
-
if(!pathname){
|
139
|
+
installApp(pathname, rmidir, rmidiri) {
|
140
|
+
if (!pathname) {
|
135
141
|
return;
|
136
142
|
}
|
137
143
|
const apppath = path.resolve(process.cwd(), pathname);
|
138
|
-
const appConfpath = path.join(apppath,
|
139
|
-
const appPackagepath = path.join(apppath,
|
140
|
-
if(fs.existsSync(apppath) && fs.existsSync(appConfpath)){
|
141
|
-
const c = jsYaml.load(
|
142
|
-
|
144
|
+
const appConfpath = path.join(apppath, "app.yaml");
|
145
|
+
const appPackagepath = path.join(apppath, "package.json");
|
146
|
+
if (fs.existsSync(apppath) && fs.existsSync(appConfpath)) {
|
147
|
+
const c = jsYaml.load(
|
148
|
+
fs.readFileSync(appConfpath, { encoding: "utf-8" }),
|
149
|
+
);
|
150
|
+
const p = JSON.parse(
|
151
|
+
fs.readFileSync(appPackagepath, { encoding: "utf-8" }),
|
152
|
+
);
|
143
153
|
const pname = c.package;
|
144
|
-
const installPath = path.join(conf({}).create(pname).root,
|
154
|
+
const installPath = path.join(conf({}).create(pname).root, "app");
|
145
155
|
const rl = readline.createInterface({
|
146
156
|
input: process.stdin,
|
147
|
-
output: process.stdout
|
148
|
-
});
|
149
|
-
log(
|
150
|
-
log("Package: "+p.name+
|
151
|
-
if(p.description){
|
152
|
-
log("Description: "+p.description);
|
157
|
+
output: process.stdout,
|
158
|
+
});
|
159
|
+
log("Installing " + pname);
|
160
|
+
log("Package: " + p.name + "@" + p.version);
|
161
|
+
if (p.description) {
|
162
|
+
log("Description: " + p.description);
|
153
163
|
}
|
154
|
-
rl.question(logget(
|
155
|
-
if(f.toLowerCase() ==
|
156
|
-
if(fs.existsSync(installPath)){
|
164
|
+
rl.question(logget("Install " + pname + "? (y/N)"), (f) => {
|
165
|
+
if (f.toLowerCase() == "y") {
|
166
|
+
if (fs.existsSync(installPath)) {
|
157
167
|
execSync(`rm -r ${installPath}`);
|
158
168
|
}
|
159
169
|
execSync(`cp -r ${apppath} ${installPath}`);
|
160
|
-
if(rmidir){
|
170
|
+
if (rmidir) {
|
161
171
|
execSync(`rm -r ${apppath}`);
|
162
172
|
}
|
163
|
-
log(
|
173
|
+
log("Installed " + pname, ":end");
|
164
174
|
rl.close();
|
165
175
|
} else {
|
166
|
-
if(rmidiri){
|
176
|
+
if (rmidiri) {
|
167
177
|
execSync(`rm -r ${apppath}`);
|
168
178
|
}
|
169
|
-
log(
|
179
|
+
log("Canceled install", ":end");
|
170
180
|
rl.close();
|
171
181
|
}
|
172
182
|
});
|
173
183
|
} else {
|
174
|
-
log(
|
184
|
+
log("Path is not a rew app", ":end");
|
175
185
|
}
|
176
186
|
},
|
177
|
-
async cloneGit(gitpath){
|
178
|
-
const p = gitpath.split(
|
187
|
+
async cloneGit(gitpath) {
|
188
|
+
const p = gitpath.split("github:")[1];
|
179
189
|
const url = `https://github.com/${p}`;
|
180
190
|
const apiurl = `https://api.github.com/repos/${p}`;
|
181
191
|
return await fetch(apiurl)
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
192
|
+
.then((r) => {
|
193
|
+
if (r.status !== 200) return log("Repo not found", ":end");
|
194
|
+
const tempPath =
|
195
|
+
"/tmp/rew-git-clone-" +
|
196
|
+
p.replace(/\//g, "_") +
|
197
|
+
"-" +
|
198
|
+
generateRandomID();
|
199
|
+
execSync(`git clone ${url} ${tempPath}`);
|
200
|
+
console.log("Installing deps...");
|
201
|
+
execSync(`cd ${tempPath} && npm i`);
|
202
|
+
return tempPath;
|
203
|
+
})
|
204
|
+
.catch((r) => null);
|
205
|
+
},
|
206
|
+
};
|
package/lib/rew/const/default.js
CHANGED
@@ -5,8 +5,26 @@ const future = require("../functions/future");
|
|
5
5
|
const sleep = require("../functions/sleep");
|
6
6
|
const { match } = require("../functions/match");
|
7
7
|
const { map } = require("../functions/map");
|
8
|
-
const {
|
9
|
-
|
8
|
+
const {
|
9
|
+
typex,
|
10
|
+
typeis,
|
11
|
+
typedef,
|
12
|
+
typei,
|
13
|
+
int,
|
14
|
+
float,
|
15
|
+
num,
|
16
|
+
str,
|
17
|
+
bool,
|
18
|
+
} = require("../functions/types");
|
19
|
+
const {
|
20
|
+
isEmpty,
|
21
|
+
clone,
|
22
|
+
deepClone,
|
23
|
+
merge,
|
24
|
+
uniqueId,
|
25
|
+
compose,
|
26
|
+
curry,
|
27
|
+
} = require("../functions/core");
|
10
28
|
const { print, input } = require("../functions/stdout");
|
11
29
|
|
12
30
|
module.exports = {
|
@@ -38,5 +56,5 @@ module.exports = {
|
|
38
56
|
curry,
|
39
57
|
|
40
58
|
print,
|
41
|
-
input
|
59
|
+
input,
|
42
60
|
};
|
package/lib/rew/const/files.js
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
const fs = require(
|
2
|
-
const path = require(
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
3
|
|
4
|
-
const HOME_PATH = path.resolve(process.env.HOME,
|
5
|
-
const THEME_PATH = module.exports.THEME_PATH = path.resolve(
|
4
|
+
const HOME_PATH = path.resolve(process.env.HOME, ".config/rew/default");
|
5
|
+
const THEME_PATH = (module.exports.THEME_PATH = path.resolve(
|
6
|
+
HOME_PATH,
|
7
|
+
"theme.css",
|
8
|
+
));
|
6
9
|
|
7
10
|
module.exports.FILES = [
|
8
11
|
{
|
9
|
-
path: HOME_PATH
|
12
|
+
path: HOME_PATH,
|
10
13
|
},
|
11
14
|
{
|
12
15
|
path: THEME_PATH,
|
13
|
-
content: fs.readFileSync(path.resolve(__dirname,
|
14
|
-
}
|
15
|
-
]
|
16
|
+
content: fs.readFileSync(path.resolve(__dirname, "../css/theme.css")),
|
17
|
+
},
|
18
|
+
];
|
package/lib/rew/const/opt.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
const execOptions = {
|
2
2
|
sharedContext: true,
|
3
|
-
resolveExtensions: [{ext:
|
3
|
+
resolveExtensions: [{ ext: ".js", options: { type: "js" } }, ".coffee"],
|
4
4
|
nativeRequire: false,
|
5
|
-
cwdAlias:
|
6
|
-
jsxPragma:
|
7
|
-
jsx: false
|
8
|
-
}
|
5
|
+
cwdAlias: "$",
|
6
|
+
jsxPragma: "createElement",
|
7
|
+
jsx: false,
|
8
|
+
};
|
9
9
|
|
10
|
-
module.exports.execOptions = execOptions;
|
10
|
+
module.exports.execOptions = execOptions;
|
package/lib/rew/css/theme.css
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
function isEmpty(value) {
|
4
|
-
if (Array.isArray(value) || typeof value ===
|
2
|
+
if (Array.isArray(value) || typeof value === "string") {
|
5
3
|
return value.length === 0;
|
6
|
-
} else if (typeof value ===
|
4
|
+
} else if (typeof value === "object") {
|
7
5
|
return Object.keys(value).length === 0;
|
8
6
|
} else {
|
9
7
|
return true;
|
@@ -13,7 +11,7 @@ function isEmpty(value) {
|
|
13
11
|
function clone(value) {
|
14
12
|
if (Array.isArray(value)) {
|
15
13
|
return value.slice();
|
16
|
-
} else if (typeof value ===
|
14
|
+
} else if (typeof value === "object") {
|
17
15
|
return Object.assign({}, value);
|
18
16
|
} else {
|
19
17
|
return value;
|
@@ -22,8 +20,8 @@ function clone(value) {
|
|
22
20
|
|
23
21
|
function deepClone(value) {
|
24
22
|
if (Array.isArray(value)) {
|
25
|
-
return value.map(item => deepClone(item));
|
26
|
-
} else if (typeof value ===
|
23
|
+
return value.map((item) => deepClone(item));
|
24
|
+
} else if (typeof value === "object") {
|
27
25
|
const obj = {};
|
28
26
|
for (const key in value) {
|
29
27
|
if (value.hasOwnProperty(key)) {
|
@@ -57,7 +55,7 @@ function reduce(arr, fn, initial) {
|
|
57
55
|
}
|
58
56
|
|
59
57
|
function compose(...fns) {
|
60
|
-
return initialValue => {
|
58
|
+
return (initialValue) => {
|
61
59
|
return fns.reduceRight((acc, fn) => fn(acc), initialValue);
|
62
60
|
};
|
63
61
|
}
|
@@ -82,5 +80,5 @@ module.exports = {
|
|
82
80
|
filter,
|
83
81
|
reduce,
|
84
82
|
compose,
|
85
|
-
curry
|
83
|
+
curry,
|
86
84
|
};
|
@@ -11,11 +11,11 @@ module.exports = function emitter() {
|
|
11
11
|
};
|
12
12
|
const off = (event, callback, removable = null) => {
|
13
13
|
const rm = (event) => {
|
14
|
-
if(removable){
|
14
|
+
if (removable) {
|
15
15
|
removable(event);
|
16
16
|
}
|
17
17
|
events.splice(events.indexOf(event), 1);
|
18
|
-
}
|
18
|
+
};
|
19
19
|
const rmEvent = (event) => {
|
20
20
|
if (callback) {
|
21
21
|
const _events = events.filter(({ callback: c }) => c == callback);
|
@@ -1,27 +1,31 @@
|
|
1
|
-
const shell = require(
|
2
|
-
|
1
|
+
const shell = require("child_process");
|
3
2
|
|
4
3
|
module.exports = (currentFile) => {
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
function exec(command, options) {
|
5
|
+
return shell.execSync(command, {
|
6
|
+
stdio: options?.output == false ? null : "inherit",
|
7
|
+
});
|
8
8
|
}
|
9
9
|
|
10
|
-
exec.background = function execAsync(command, options, callback){
|
11
|
-
if(typeof options == "function" && !callback){
|
10
|
+
exec.background = function execAsync(command, options, callback) {
|
11
|
+
if (typeof options == "function" && !callback) {
|
12
12
|
callback = options;
|
13
13
|
options = {};
|
14
14
|
}
|
15
|
-
if(!options) options = {};
|
16
|
-
if(!callback) callback = () => {};
|
17
|
-
return shell.exec(
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
if (!options) options = {};
|
16
|
+
if (!callback) callback = () => {};
|
17
|
+
return shell.exec(
|
18
|
+
command,
|
19
|
+
{
|
20
|
+
...options,
|
21
|
+
},
|
22
|
+
callback,
|
23
|
+
);
|
24
|
+
};
|
21
25
|
|
22
|
-
function spawn(command, options){
|
26
|
+
function spawn(command, options) {
|
23
27
|
return shell.spawn(command, options);
|
24
28
|
}
|
25
29
|
|
26
30
|
return { exec, spawn };
|
27
|
-
}
|
31
|
+
};
|
@@ -1,17 +1,16 @@
|
|
1
|
-
|
2
|
-
function exportsThe(item, name, context){
|
1
|
+
function exportsThe(item, name, context) {
|
3
2
|
if (name) {
|
4
|
-
if(!context.module.exports) context.module.exports = {};
|
3
|
+
if (!context.module.exports) context.module.exports = {};
|
5
4
|
context.module.exports[name] = item;
|
6
5
|
} else {
|
7
|
-
if(context.module.exports) context.module.exports.default = item;
|
6
|
+
if (context.module.exports) context.module.exports.default = item;
|
8
7
|
else context.module.exports = item;
|
9
8
|
}
|
10
9
|
}
|
11
10
|
|
12
11
|
module.exports.pubFunction = function (context) {
|
13
12
|
return function (name, item) {
|
14
|
-
if(name && !item){
|
13
|
+
if (name && !item) {
|
15
14
|
item = name;
|
16
15
|
name = null;
|
17
16
|
}
|
@@ -24,4 +23,3 @@ module.exports.exportsFunction = function (context) {
|
|
24
23
|
exportsThe(item, name, context);
|
25
24
|
};
|
26
25
|
};
|
27
|
-
|
package/lib/rew/functions/fs.js
CHANGED
@@ -1,47 +1,50 @@
|
|
1
|
-
const fs = require(
|
2
|
-
const path = require(
|
3
|
-
const { execOptions } = require(
|
4
|
-
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const { execOptions } = require("../const/opt");
|
5
4
|
|
6
5
|
module.exports = (currentFile) => {
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
function gp(filepath) {
|
7
|
+
return path.resolve(
|
8
|
+
filepath.startsWith(execOptions.cwdAlias)
|
9
|
+
? process.cwd()
|
10
|
+
: path.dirname(currentFile),
|
11
|
+
filepath.replaceAll(execOptions.cwdAlias + "/", ""),
|
12
|
+
);
|
10
13
|
}
|
11
14
|
|
12
|
-
function read(filepath, options = { encoding:
|
15
|
+
function read(filepath, options = { encoding: "utf-8" }) {
|
13
16
|
return fs.readFileSync(gp(filepath), options);
|
14
17
|
}
|
15
18
|
|
16
|
-
function realpath(filepath, options = { encoding:
|
19
|
+
function realpath(filepath, options = { encoding: "utf-8" }) {
|
17
20
|
return gp(filepath);
|
18
21
|
}
|
19
22
|
|
20
|
-
function write(filepath, content, options){
|
23
|
+
function write(filepath, content, options) {
|
21
24
|
return fs.writeFileSync(gp(filepath), content, options);
|
22
25
|
}
|
23
26
|
|
24
|
-
function exists(filepath, options){
|
27
|
+
function exists(filepath, options) {
|
25
28
|
return fs.existsSync(gp(filepath));
|
26
29
|
}
|
27
30
|
|
28
|
-
function fstat(filepath, options){
|
31
|
+
function fstat(filepath, options) {
|
29
32
|
return fs.statSync(gp(filepath), options);
|
30
33
|
}
|
31
34
|
|
32
|
-
function rm(filepath, options){
|
35
|
+
function rm(filepath, options) {
|
33
36
|
return fs.unlinkSync(filepath);
|
34
37
|
}
|
35
38
|
|
36
|
-
function chmod(filepath, mode, options){
|
39
|
+
function chmod(filepath, mode, options) {
|
37
40
|
return fs.chmodSync(gp(filepath), mode);
|
38
41
|
}
|
39
42
|
|
40
|
-
function mkdir(filepath, options){
|
43
|
+
function mkdir(filepath, options) {
|
41
44
|
return fs.mkdirSync(gp(filepath), options);
|
42
45
|
}
|
43
46
|
|
44
|
-
function ls(filepath, options){
|
47
|
+
function ls(filepath, options) {
|
45
48
|
return fs.readdirSync(gp(filepath), options);
|
46
49
|
}
|
47
50
|
|
@@ -54,6 +57,6 @@ module.exports = (currentFile) => {
|
|
54
57
|
exists,
|
55
58
|
write,
|
56
59
|
read,
|
57
|
-
realpath
|
60
|
+
realpath,
|
58
61
|
};
|
59
|
-
}
|
62
|
+
};
|
@@ -18,6 +18,6 @@ module.exports = function future(callback, timeout = 0, defData = null) {
|
|
18
18
|
catch: (callback) => promise.catch(callback),
|
19
19
|
resolve: (data) => listener.emit("resolve", data),
|
20
20
|
reject: (data) => listener.emit("reject", data),
|
21
|
-
wait: async () => await promise
|
21
|
+
wait: async () => await promise,
|
22
22
|
};
|
23
23
|
};
|