-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds support for relative paths in Worker. Paths are relative to the current working directory. PR-URL: #21407 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
- Loading branch information
1 parent
8f1aa3c
commit 206e5bf
Showing
7 changed files
with
64 additions
and
20 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Flags: --experimental-worker | ||
'use strict'; | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const common = require('../common'); | ||
const { Worker, isMainThread, parentPort } = require('worker_threads'); | ||
|
||
if (isMainThread) { | ||
const cwdName = path.relative('../', '.'); | ||
const relativePath = path.relative('.', __filename); | ||
const w = new Worker(path.join('..', cwdName, relativePath)); | ||
w.on('message', common.mustCall((message) => { | ||
assert.strictEqual(message, 'Hello, world!'); | ||
})); | ||
} else { | ||
parentPort.postMessage('Hello, world!'); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Flags: --experimental-worker | ||
'use strict'; | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const common = require('../common'); | ||
const { Worker, isMainThread, parentPort } = require('worker_threads'); | ||
|
||
if (isMainThread) { | ||
const w = new Worker('./' + path.relative('.', __filename)); | ||
w.on('message', common.mustCall((message) => { | ||
assert.strictEqual(message, 'Hello, world!'); | ||
})); | ||
} else { | ||
parentPort.postMessage('Hello, world!'); | ||
} |
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