替换 spawn 为 cross-spawn

This commit is contained in:
whyour 2023-05-31 14:25:20 +08:00
parent 0bbb7c7b89
commit a7f97bd729
7 changed files with 21 additions and 9 deletions

View File

@ -2,7 +2,7 @@ import { Service, Inject } from 'typedi';
import winston from 'winston';
import config from '../config';
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
import { exec, execSync, spawn } from 'child_process';
import { exec, execSync } from 'child_process';
import fs from 'fs';
import cron_parser from 'cron-parser';
import {
@ -17,6 +17,7 @@ import path from 'path';
import { TASK_PREFIX, QL_PREFIX } from '../config/const';
import cronClient from '../schedule/client';
import { runCronWithLimit } from '../shared/pLimit';
import { spawn } from 'cross-spawn';
@Service()
export default class CronService {

View File

@ -9,7 +9,7 @@ import {
unInstallDependenceCommandTypes,
DependenceModel,
} from '../data/dependence';
import { spawn } from 'child_process';
import { spawn } from 'cross-spawn';
import SockService from './sock';
import { FindOptions, Op } from 'sequelize';
import { concurrentRun } from '../config/util';

View File

@ -1,7 +1,7 @@
import { Service, Inject } from 'typedi';
import winston from 'winston';
import nodeSchedule from 'node-schedule';
import { ChildProcessWithoutNullStreams, exec, spawn } from 'child_process';
import { ChildProcessWithoutNullStreams } from 'child_process';
import {
ToadScheduler,
LongIntervalJob,
@ -10,6 +10,7 @@ import {
} from 'toad-scheduler';
import dayjs from 'dayjs';
import { runCronWithLimit } from '../shared/pLimit';
import { spawn } from 'cross-spawn';
interface ScheduleTaskType {
id: number;

View File

@ -6,7 +6,7 @@ import { AuthDataType, AuthInfo, AuthModel, LoginStatus } from '../data/auth';
import { NotificationInfo } from '../data/notify';
import NotificationService from './notify';
import ScheduleService, { TaskCallbacks } from './schedule';
import { spawn } from 'child_process';
import { spawn } from 'cross-spawn';
import SockService from './sock';
import got from 'got';
import {

View File

@ -1,4 +1,4 @@
import { spawn } from "child_process";
import { spawn } from 'cross-spawn';
import { runCronWithLimit } from "./pLimit";
import Logger from '../loaders/logger';

View File

@ -64,6 +64,7 @@
"chokidar": "^3.5.3",
"cors": "^2.8.5",
"cron-parser": "^4.2.1",
"cross-spawn": "^7.0.3",
"dayjs": "^1.11.2",
"dotenv": "^16.0.0",
"express": "^4.17.3",
@ -104,6 +105,7 @@
"@sentry/react": "^7.12.1",
"@types/body-parser": "^1.19.2",
"@types/cors": "^2.8.12",
"@types/cross-spawn": "^6.0.2",
"@types/express": "^4.17.13",
"@types/express-jwt": "^6.0.4",
"@types/js-yaml": "^4.0.5",

View File

@ -28,6 +28,9 @@ dependencies:
cron-parser:
specifier: ^4.2.1
version: 4.8.1
cross-spawn:
specifier: ^7.0.3
version: 7.0.3
dayjs:
specifier: ^1.11.2
version: 1.11.7
@ -144,6 +147,9 @@ devDependencies:
'@types/cors':
specifier: ^2.8.12
version: 2.8.13
'@types/cross-spawn':
specifier: ^6.0.2
version: 6.0.2
'@types/express':
specifier: ^4.17.13
version: 4.17.17
@ -4224,6 +4230,12 @@ packages:
'@types/node': 17.0.45
dev: true
/@types/cross-spawn@6.0.2:
resolution: {integrity: sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw==}
dependencies:
'@types/node': 17.0.45
dev: true
/@types/debug@4.1.7:
resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==}
dependencies:
@ -6847,7 +6859,6 @@ packages:
path-key: 3.1.1
shebang-command: 2.0.0
which: 2.0.2
dev: true
/crypto-browserify@3.12.0:
resolution: {integrity: sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==}
@ -10989,7 +11000,6 @@ packages:
/path-key@3.1.1:
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
engines: {node: '>=8'}
dev: true
/path-key@4.0.0:
resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==}
@ -13699,7 +13709,6 @@ packages:
engines: {node: '>=8'}
dependencies:
shebang-regex: 3.0.0
dev: true
/shebang-regex@1.0.0:
resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==}
@ -13709,7 +13718,6 @@ packages:
/shebang-regex@3.0.0:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'}
dev: true
/shell-quote@1.8.1:
resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==}