Skip to content

Commit

Permalink
refactor: modify worker file path to satisfy the dependency analysis (#…
Browse files Browse the repository at this point in the history
…72)

* chore: modify worker file path to satisfy the dependency analysis

* chore: also rewrite process file path

* chore: remove unnecessary comment

* chore: remove unnecessary comment

---------

Co-authored-by: wujin <wujin@qunhemail.com>
Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com>
  • Loading branch information
3 people committed Sep 15, 2023
1 parent a5b6669 commit f3c1623
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/runtime/process-worker.ts
@@ -1,6 +1,5 @@
import { ChildProcess, fork } from 'child_process'
import { MessagePort, TransferListItem } from 'worker_threads'
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import {
TinypoolChannel,
Expand All @@ -21,9 +20,10 @@ export default class ProcessWorker implements TinypoolWorker {
waitForExit!: Promise<void>

initialize(options: Parameters<TinypoolWorker['initialize']>[0]) {
const __dirname = dirname(fileURLToPath(import.meta.url))

this.process = fork(resolve(__dirname, './entry/process.js'), options)
this.process = fork(
fileURLToPath(import.meta.url + '/../entry/process.js'),
options
)
this.threadId = this.process.pid!

this.process.on('exit', this.onUnexpectedExit)
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/thread-worker.ts
@@ -1,5 +1,4 @@
import { fileURLToPath } from 'url'
import { dirname, resolve } from 'path'
import { TransferListItem, Worker } from 'worker_threads'
import { TinypoolWorker } from '../common'

Expand All @@ -10,9 +9,10 @@ export default class ThreadWorker implements TinypoolWorker {
threadId!: number

initialize(options: Parameters<TinypoolWorker['initialize']>[0]) {
const __dirname = dirname(fileURLToPath(import.meta.url))

this.thread = new Worker(resolve(__dirname, './entry/worker.js'), options)
this.thread = new Worker(
fileURLToPath(import.meta.url + '/../entry/worker.js'),
options
)
this.threadId = this.thread.threadId
}

Expand Down

0 comments on commit f3c1623

Please sign in to comment.