@whyour/qinglong 2.17.9-rc.3 → 2.17.9-rc.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "2.17.9-rc.3",
3
+ "version": "2.17.9-rc.5",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,13 +1,5 @@
1
1
  const { execSync } = require('child_process');
2
- const { sendNotify } = require('./notify.js');
3
2
  require(`./env.js`);
4
-
5
- function initGlobal() {
6
- global.QLAPI = {
7
- notify: sendNotify,
8
- };
9
- }
10
-
11
3
  function expandRange(rangeStr, max) {
12
4
  const tempRangeStr = rangeStr
13
5
  .trim()
@@ -45,10 +37,8 @@ function run() {
45
37
  const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
46
38
  let command = `bash -c "source ${file_task_before} ${fileName}`;
47
39
  if (task_before) {
48
- command = `${command} && echo -e '执行前置命令\n' && eval '${task_before.replace(
49
- /"/g,
50
- '\\"',
51
- )}' && echo -e '\n执行前置命令结束\n'`;
40
+ const escapeTaskBefore = task_before.replace(/"/g, '\\"');
41
+ command = `${command} && echo -e '执行前置命令\n' && eval '${escapeTaskBefore}' && echo -e '\n执行前置命令结束\n'`;
52
42
  }
53
43
  const res = execSync(
54
44
  `${command} && echo -e '${splitStr}' && NODE_OPTIONS= node -p 'JSON.stringify(process.env)'"`,
@@ -78,8 +68,12 @@ function run() {
78
68
  }
79
69
 
80
70
  try {
81
- initGlobal();
82
71
  run();
72
+
73
+ const { sendNotify } = require('./notify.js');
74
+ global.QLAPI = {
75
+ notify: sendNotify,
76
+ };
83
77
  } catch (error) {
84
78
  console.log(`run builtin code error: `, error, '\n');
85
79
  }
@@ -5,17 +5,6 @@ import json
5
5
  import builtins
6
6
  import sys
7
7
  import env
8
- from notify import send
9
-
10
-
11
- class BaseApi:
12
- def notify(self, *args, **kwargs):
13
- return send(*args, **kwargs)
14
-
15
-
16
- def init_global():
17
- QLAPI = BaseApi()
18
- builtins.QLAPI = QLAPI
19
8
 
20
9
 
21
10
  def try_parse_int(value):
@@ -55,7 +44,8 @@ def run():
55
44
  task_before = os.getenv("task_before")
56
45
 
57
46
  if task_before:
58
- command += f" && echo -e '执行前置命令\n' && eval '{task_before.replace('"', '\\"')}' && echo -e '\n执行前置命令结束\n'"
47
+ escape_task_before = task_before.replace('"', '\\"')
48
+ command += f" && echo -e '执行前置命令\n' && eval '{escape_task_before}' && echo -e '\n执行前置命令结束\n'"
59
49
 
60
50
  python_command = "PYTHONPATH= python3 -c 'import os, json; print(json.dumps(dict(os.environ)))'"
61
51
  command += f" && echo -e '{split_str}' && {python_command}\""
@@ -91,7 +81,15 @@ def run():
91
81
 
92
82
 
93
83
  try:
94
- init_global()
95
84
  run()
85
+
86
+ from notify import send
87
+
88
+ class BaseApi:
89
+ def notify(self, *args, **kwargs):
90
+ return send(*args, **kwargs)
91
+
92
+ QLAPI = BaseApi()
93
+ builtins.QLAPI = QLAPI
96
94
  except Exception as error:
97
95
  print(f"run builtin code error: {error}\n")