mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 17:32:22 +00:00

Move tmpdir functionality to its own module (common/tmpdir). PR-URL: https://github.com/nodejs/node/pull/17856 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
24 lines
651 B
JavaScript
24 lines
651 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
if (cluster.isMaster) {
|
|
tmpdir.refresh();
|
|
|
|
assert.strictEqual(cluster.settings.cwd, undefined);
|
|
cluster.fork().on('message', common.mustCall((msg) => {
|
|
assert.strictEqual(msg, process.cwd());
|
|
}));
|
|
|
|
cluster.setupMaster({ cwd: tmpdir.path });
|
|
assert.strictEqual(cluster.settings.cwd, tmpdir.path);
|
|
cluster.fork().on('message', common.mustCall((msg) => {
|
|
assert.strictEqual(msg, tmpdir.path);
|
|
}));
|
|
} else {
|
|
process.send(process.cwd());
|
|
process.disconnect();
|
|
}
|