forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: avoid circular dependency in SyncWriteStream
Previously, there was a circular dependency on the public fs module in SyncWriteStream. Moving the implementations of fs.writeSync and fs.closeSync to internal/fs allows us to avoid that circular dependency. Fixes: nodejs#11257
- Loading branch information
Showing
3 changed files
with
59 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const execSync = require('child_process').execSync; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Prevents a regression where redirecting stderr and receiving input script | ||
// via stdin works properly. | ||
|
||
common.refreshTmpDir(); | ||
const filename = path.join(common.fixturesDir, 'baz.js'); | ||
const out = path.join(common.tmpDir, 'js.out'); | ||
const bin = process.execPath; | ||
const input = `require('${filename}'); console.log('PASS');`; | ||
const cmd = common.isWindows ? | ||
`echo "${input}" | ${bin} > ${out} 2>&1` : | ||
`echo "${input}" | ${bin} &> ${out}`; | ||
|
||
// This will throw if internal/fs has a circular dependency. | ||
assert.strictEqual(execSync(cmd).toString(), ''); | ||
|
||
const result = fs.readFileSync(out, 'utf8').trim(); | ||
assert.strictEqual(result, 'PASS'); | ||
|
||
fs.unlinkSync(out); |