@elinzy/core 0.1.0 → 0.1.2
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/dist/child_process.cjs +36 -20
- package/dist/child_process.mjs +36 -20
- package/package.json +4 -19
package/dist/child_process.cjs
CHANGED
|
@@ -4,59 +4,75 @@ var execa = require('execa');
|
|
|
4
4
|
var c = require('ansis');
|
|
5
5
|
|
|
6
6
|
function exec(cmd, args, opts) {
|
|
7
|
-
|
|
7
|
+
opts = {
|
|
8
|
+
throwOnError: true,
|
|
9
|
+
...opts
|
|
10
|
+
};
|
|
11
|
+
if (opts.logger || opts.dryRun)
|
|
8
12
|
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
9
|
-
if (opts
|
|
13
|
+
if (opts.dryRun)
|
|
10
14
|
return Promise.resolve(void 0);
|
|
11
|
-
return execa.execa(cmd, args, opts).then((spawned) => opts
|
|
12
|
-
if (opts
|
|
15
|
+
return execa.execa(cmd, args, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
|
|
16
|
+
if (opts.throwOnError)
|
|
13
17
|
throw new Error(
|
|
14
|
-
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts
|
|
18
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
15
19
|
);
|
|
16
20
|
return Promise.resolve(void 0);
|
|
17
21
|
});
|
|
18
22
|
}
|
|
19
23
|
function execSync(cmd, args, opts) {
|
|
20
|
-
|
|
24
|
+
opts = {
|
|
25
|
+
throwOnError: true,
|
|
26
|
+
...opts
|
|
27
|
+
};
|
|
28
|
+
if (opts.logger || opts.dryRun)
|
|
21
29
|
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
22
|
-
if (opts
|
|
30
|
+
if (opts.dryRun)
|
|
23
31
|
return void 0;
|
|
24
32
|
try {
|
|
25
33
|
const spawned = execa.execaSync(cmd, args, opts);
|
|
26
|
-
return opts
|
|
34
|
+
return opts.abbrev ? spawned.stdout : spawned;
|
|
27
35
|
} catch (e) {
|
|
28
|
-
if (opts?.throwOnError
|
|
36
|
+
if (opts?.throwOnError)
|
|
29
37
|
throw new Error(
|
|
30
|
-
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts
|
|
38
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
31
39
|
);
|
|
32
40
|
return void 0;
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
43
|
function execCommand(cmd, opts) {
|
|
36
|
-
|
|
44
|
+
opts = {
|
|
45
|
+
throwOnError: true,
|
|
46
|
+
...opts
|
|
47
|
+
};
|
|
48
|
+
if (opts.logger || opts.dryRun)
|
|
37
49
|
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
38
|
-
if (opts
|
|
50
|
+
if (opts.dryRun)
|
|
39
51
|
return Promise.resolve(void 0);
|
|
40
|
-
return execa.execaCommand(cmd, opts).then((spawned) => opts
|
|
41
|
-
if (opts
|
|
52
|
+
return execa.execaCommand(cmd, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
|
|
53
|
+
if (opts.throwOnError)
|
|
42
54
|
throw new Error(
|
|
43
|
-
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts
|
|
55
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
44
56
|
);
|
|
45
57
|
return Promise.resolve(void 0);
|
|
46
58
|
});
|
|
47
59
|
}
|
|
48
60
|
function execCommandSync(cmd, opts) {
|
|
49
|
-
|
|
61
|
+
opts = {
|
|
62
|
+
throwOnError: true,
|
|
63
|
+
...opts
|
|
64
|
+
};
|
|
65
|
+
if (opts.logger || opts.dryRun)
|
|
50
66
|
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
51
|
-
if (opts
|
|
67
|
+
if (opts.dryRun)
|
|
52
68
|
return void 0;
|
|
53
69
|
try {
|
|
54
70
|
const spawned = execa.execaCommandSync(cmd, opts);
|
|
55
|
-
return opts
|
|
71
|
+
return opts.abbrev ? spawned.stdout : spawned;
|
|
56
72
|
} catch (e) {
|
|
57
|
-
if (opts
|
|
73
|
+
if (opts.throwOnError)
|
|
58
74
|
throw new Error(
|
|
59
|
-
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts
|
|
75
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
60
76
|
);
|
|
61
77
|
return void 0;
|
|
62
78
|
}
|
package/dist/child_process.mjs
CHANGED
|
@@ -2,59 +2,75 @@ import { execa, execaSync, execaCommand, execaCommandSync } from 'execa';
|
|
|
2
2
|
import c from 'ansis';
|
|
3
3
|
|
|
4
4
|
function exec(cmd, args, opts) {
|
|
5
|
-
|
|
5
|
+
opts = {
|
|
6
|
+
throwOnError: true,
|
|
7
|
+
...opts
|
|
8
|
+
};
|
|
9
|
+
if (opts.logger || opts.dryRun)
|
|
6
10
|
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
7
|
-
if (opts
|
|
11
|
+
if (opts.dryRun)
|
|
8
12
|
return Promise.resolve(void 0);
|
|
9
|
-
return execa(cmd, args, opts).then((spawned) => opts
|
|
10
|
-
if (opts
|
|
13
|
+
return execa(cmd, args, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
|
|
14
|
+
if (opts.throwOnError)
|
|
11
15
|
throw new Error(
|
|
12
|
-
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts
|
|
16
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
13
17
|
);
|
|
14
18
|
return Promise.resolve(void 0);
|
|
15
19
|
});
|
|
16
20
|
}
|
|
17
21
|
function execSync(cmd, args, opts) {
|
|
18
|
-
|
|
22
|
+
opts = {
|
|
23
|
+
throwOnError: true,
|
|
24
|
+
...opts
|
|
25
|
+
};
|
|
26
|
+
if (opts.logger || opts.dryRun)
|
|
19
27
|
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
20
|
-
if (opts
|
|
28
|
+
if (opts.dryRun)
|
|
21
29
|
return void 0;
|
|
22
30
|
try {
|
|
23
31
|
const spawned = execaSync(cmd, args, opts);
|
|
24
|
-
return opts
|
|
32
|
+
return opts.abbrev ? spawned.stdout : spawned;
|
|
25
33
|
} catch (e) {
|
|
26
|
-
if (opts?.throwOnError
|
|
34
|
+
if (opts?.throwOnError)
|
|
27
35
|
throw new Error(
|
|
28
|
-
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts
|
|
36
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
29
37
|
);
|
|
30
38
|
return void 0;
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
function execCommand(cmd, opts) {
|
|
34
|
-
|
|
42
|
+
opts = {
|
|
43
|
+
throwOnError: true,
|
|
44
|
+
...opts
|
|
45
|
+
};
|
|
46
|
+
if (opts.logger || opts.dryRun)
|
|
35
47
|
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
36
|
-
if (opts
|
|
48
|
+
if (opts.dryRun)
|
|
37
49
|
return Promise.resolve(void 0);
|
|
38
|
-
return execaCommand(cmd, opts).then((spawned) => opts
|
|
39
|
-
if (opts
|
|
50
|
+
return execaCommand(cmd, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
|
|
51
|
+
if (opts.throwOnError)
|
|
40
52
|
throw new Error(
|
|
41
|
-
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts
|
|
53
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
42
54
|
);
|
|
43
55
|
return Promise.resolve(void 0);
|
|
44
56
|
});
|
|
45
57
|
}
|
|
46
58
|
function execCommandSync(cmd, opts) {
|
|
47
|
-
|
|
59
|
+
opts = {
|
|
60
|
+
throwOnError: true,
|
|
61
|
+
...opts
|
|
62
|
+
};
|
|
63
|
+
if (opts.logger || opts.dryRun)
|
|
48
64
|
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
49
|
-
if (opts
|
|
65
|
+
if (opts.dryRun)
|
|
50
66
|
return void 0;
|
|
51
67
|
try {
|
|
52
68
|
const spawned = execaCommandSync(cmd, opts);
|
|
53
|
-
return opts
|
|
69
|
+
return opts.abbrev ? spawned.stdout : spawned;
|
|
54
70
|
} catch (e) {
|
|
55
|
-
if (opts
|
|
71
|
+
if (opts.throwOnError)
|
|
56
72
|
throw new Error(
|
|
57
|
-
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts
|
|
73
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
58
74
|
);
|
|
59
75
|
return void 0;
|
|
60
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elinzy/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "e core implementation module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -27,12 +27,11 @@
|
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
29
|
"url": "git+https://github.com/Appleec/e.git",
|
|
30
|
-
"directory": "packages/
|
|
30
|
+
"directory": "packages/core"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
33
|
"e",
|
|
34
|
-
"core"
|
|
35
|
-
"e-core"
|
|
34
|
+
"core"
|
|
36
35
|
],
|
|
37
36
|
"author": "Appleec <771992522@qq.com>",
|
|
38
37
|
"license": "MIT",
|
|
@@ -40,23 +39,9 @@
|
|
|
40
39
|
"url": "https://github.com/Appleec/e/issues"
|
|
41
40
|
},
|
|
42
41
|
"homepage": "https://github.com/Appleec/e#readme",
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@babel/core": "7.26.10",
|
|
45
|
-
"@babel/preset-env": "7.26.9",
|
|
46
|
-
"@babel/preset-typescript": "7.26.0",
|
|
47
|
-
"@rollup/plugin-babel": "6.0.4",
|
|
48
|
-
"@rollup/plugin-node-resolve": "16.0.1",
|
|
49
|
-
"rollup": "4.35.0",
|
|
50
|
-
"rollup-plugin-dts": "6.1.1",
|
|
51
|
-
"rollup-plugin-esbuild": "6.2.1",
|
|
52
|
-
"rollup-plugin-node-externals": "8.0.0",
|
|
53
|
-
"tslib": "2.8.1",
|
|
54
|
-
"typescript": "^5.8.2"
|
|
55
|
-
},
|
|
56
42
|
"dependencies": {
|
|
57
43
|
"ansis": "^3.17.0",
|
|
58
|
-
"execa": "^9.5.2"
|
|
59
|
-
"@elinzy/logger": "1.0.0"
|
|
44
|
+
"execa": "^9.5.2"
|
|
60
45
|
},
|
|
61
46
|
"scripts": {
|
|
62
47
|
"dev": "rollup --config rollup.config.mjs --watch",
|