koishi-plugin-spawn-modified 1.3.0 → 1.3.1

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 CHANGED
@@ -62,7 +62,7 @@ function apply(ctx, config) {
62
62
  ctx.i18n.define('zh-CN', require('./locales/zh-CN'));
63
63
  ctx.command('exec <command:text>', { authority: (_a = config.authority) !== null && _a !== void 0 ? _a : 4 })
64
64
  .action(function (_a, command_1) { return __awaiter(_this, [_a, command_1], void 0, function (_b, command) {
65
- var guildId, userId, userKey, isExempt, sessionId, rootDir, currentDir, filterList, filterMode, cdValidation, pathValidation, timeout, state;
65
+ var guildId, userId, userKey, isExempt, sessionId, rootDir, currentDir, fs, filterList, filterMode, cdValidation, pathValidation, timeout, state;
66
66
  var _this = this;
67
67
  var _c, _d, _e;
68
68
  var session = _b.session;
@@ -80,6 +80,10 @@ function apply(ctx, config) {
80
80
  sessionId = session.uid || session.channelId;
81
81
  rootDir = path_1.default.resolve(ctx.baseDir, config.root);
82
82
  currentDir = sessionDirs.get(sessionId) || rootDir;
83
+ fs = require('fs');
84
+ if (!fs.existsSync(currentDir)) {
85
+ return [2 /*return*/, session.text('执行目录不存在')];
86
+ }
83
87
  // 输出调试信息
84
88
  (0, logger_1.debugLog)(ctx, config, {
85
89
  guildId: guildId,
@@ -174,7 +178,7 @@ function apply(ctx, config) {
174
178
  if (process.platform !== 'win32') {
175
179
  ctx.command('sudoexec <command:text>')
176
180
  .action(function (_a, command_1) { return __awaiter(_this, [_a, command_1], void 0, function (_b, command) {
177
- var guildId, userId, userKey, isExempt, sudoPassword, sessionId, rootDir, currentDir, sudoCommand, timeout, state;
181
+ var guildId, userId, userKey, isExempt, sudoPassword, sessionId, rootDir, currentDir, fs, sudoCommand, timeout, state;
178
182
  var _this = this;
179
183
  var _c, _d;
180
184
  var session = _b.session;
@@ -197,6 +201,10 @@ function apply(ctx, config) {
197
201
  sessionId = session.uid || session.channelId;
198
202
  rootDir = path_1.default.resolve(ctx.baseDir, config.root);
199
203
  currentDir = sessionDirs.get(sessionId) || rootDir;
204
+ fs = require('fs');
205
+ if (!fs.existsSync(currentDir)) {
206
+ return [2 /*return*/, session.text('执行目录不存在')];
207
+ }
200
208
  (0, logger_1.debugLog)(ctx, config, {
201
209
  guildId: guildId,
202
210
  userId: userId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-spawn-modified",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Run shell commands with Koishi",
5
5
  "keywords": [
6
6
  "bot",
package/src/index.ts CHANGED
@@ -56,6 +56,11 @@ export function apply(ctx: Context, config: Config) {
56
56
  const sessionId = session.uid || session.channelId
57
57
  const rootDir = path.resolve(ctx.baseDir, config.root)
58
58
  const currentDir = sessionDirs.get(sessionId) || rootDir
59
+ // 检查执行目录是否存在
60
+ const fs = require('fs')
61
+ if (!fs.existsSync(currentDir)) {
62
+ return session.text('执行目录不存在')
63
+ }
59
64
 
60
65
  // 输出调试信息
61
66
  debugLog(ctx, config, {
@@ -166,6 +171,11 @@ export function apply(ctx: Context, config: Config) {
166
171
  const sessionId = session.uid || session.channelId
167
172
  const rootDir = path.resolve(ctx.baseDir, config.root)
168
173
  const currentDir = sessionDirs.get(sessionId) || rootDir
174
+ // 检查执行目录是否存在
175
+ const fs = require('fs')
176
+ if (!fs.existsSync(currentDir)) {
177
+ return session.text('执行目录不存在')
178
+ }
169
179
 
170
180
  debugLog(ctx, config, {
171
181
  guildId,