generated from l-collect/ts-dev-template
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
43 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,55 @@ | ||
import dotEnv from 'dotenv' | ||
import {fork, ForkOptions} from "child_process"; | ||
import path from "path"; | ||
import dotEnv from 'dotenv'; | ||
import { fork, ForkOptions } from 'child_process'; | ||
import path from 'path'; | ||
import * as fs from 'fs'; | ||
import { deepMerge } from '@/utils'; | ||
interface Message { | ||
type: "start" | "queue"; | ||
type: 'start' | 'queue'; | ||
body: any; | ||
} | ||
|
||
let buffer:any = null,timeStart: number; | ||
const readEnv=(filename:string)=>{ | ||
if(fs.existsSync(filename)){ | ||
return dotEnv.config({path:filename}).parsed||{} | ||
let buffer: any = null, | ||
timeStart: number; | ||
const readEnv = (filename: string) => { | ||
if (fs.existsSync(filename)) { | ||
return dotEnv.config({ path: filename }).parsed || {}; | ||
} | ||
return {} | ||
} | ||
export function startAppWorker(config:string,mode: string) { | ||
const commonEnv=readEnv(path.join(process.cwd(),'.env')) | ||
const modeEnv=deepMerge(commonEnv,readEnv(path.join(process.cwd(),`.env.${mode}`))); | ||
return {}; | ||
}; | ||
export function startAppWorker(config: string, mode: string) { | ||
const commonEnv = readEnv(path.join(process.cwd(), '.env')); | ||
const modeEnv = deepMerge(commonEnv, readEnv(path.join(process.cwd(), `.env.${mode}`))); | ||
const forkOptions: ForkOptions = { | ||
env: { | ||
...process.env, | ||
mode, | ||
config, | ||
CWD:path.resolve(__dirname,'../'), | ||
...modeEnv | ||
CWD: process.cwd(), | ||
...modeEnv, | ||
}, | ||
execArgv: ["-r", "jiti/register", "-r", "tsconfig-paths/register"], | ||
stdio: "inherit", | ||
execArgv: ['-r', 'jiti/register', '-r', 'tsconfig-paths/register'], | ||
stdio: 'inherit', | ||
}; | ||
const cp = fork(path.resolve(__dirname,"../start.js"), [ | ||
'-p tsconfig.json' | ||
], forkOptions) | ||
cp.stdout?.on("data", data => process.stdout.push(data)); | ||
cp.stderr?.on("data", data => process.stderr.push(data)); | ||
process.stdin?.on("data", data => cp.stdin?.write(data)); | ||
cp.on("message", (message: Message) => { | ||
if (message.type === "start") { | ||
const cp = fork(path.resolve(__dirname, '../start.js'), ['-p tsconfig.json'], forkOptions); | ||
cp.stdout?.on('data', data => process.stdout.push(data)); | ||
cp.stderr?.on('data', data => process.stderr.push(data)); | ||
process.stdin?.on('data', data => cp.stdin?.write(data)); | ||
cp.on('message', (message: Message) => { | ||
if (message.type === 'start') { | ||
if (buffer) { | ||
cp.send({type: "send", body: buffer, times: timeStart}); | ||
cp.send({ type: 'send', body: buffer, times: timeStart }); | ||
buffer = null; | ||
} | ||
} else if (message.type === "queue") { | ||
} else if (message.type === 'queue') { | ||
buffer = message.body; | ||
} | ||
}); | ||
cp.on("exit", code => { | ||
if(!code) return | ||
if (code!==51) { | ||
cp.on('exit', code => { | ||
if (!code) return; | ||
if (code !== 51) { | ||
process.exit(code); | ||
} | ||
timeStart = new Date().getTime(); | ||
startAppWorker(config,mode) | ||
startAppWorker(config, mode); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
node_modules/.pnpm/husky@8.0.3/node_modules/husky/README.md
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
node_modules/.pnpm/husky@8.0.3/node_modules/husky/husky.sh
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
node_modules/.pnpm/husky@8.0.3/node_modules/husky/package.json
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.