Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/parallel/test-fs-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ common.refreshTmpDir();

// test creating and reading hard link
const srcPath = path.join(common.fixturesDir, 'cycles', 'root.js');
const srcContent = fs.readFileSync(srcPath, 'utf8');
const tmpSrcPath = path.join(common.tmpDir, 'root.js');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd simplify this to e.g.:

const srcPath = path.join(common.tmpDir, 'target.txt');
fs.writeFileSync(srcPath, 'hello world');

One fewer variable.

const dstPath = path.join(common.tmpDir, 'link1.js');

const callback = function(err) {
if (err) throw err;
const srcContent = fs.readFileSync(srcPath, 'utf8');
const dstContent = fs.readFileSync(dstPath, 'utf8');
assert.strictEqual(srcContent, dstContent);
};

// copy source file to same directory to avoid cross-filesystem issues
fs.writeFileSync(tmpSrcPath, srcContent, 'utf8');

fs.link(srcPath, dstPath, common.mustCall(callback));

// test error outputs
Expand Down