Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4dce39a

Browse filesBrowse files
richardlauMylesBorins
authored andcommitted
test: use fs.copyFileSync()
Use the potentially more efficient fs.copyFileSync() instead of reading the whole file in and writing the whole file out in JavaScript. PR-URL: #20340 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent b24ee07 commit 4dce39a
Copy full SHA for 4dce39a

File tree

Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-child-process-fork-exec-path.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-fork-exec-path.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
const common = require('../common');
2424
const assert = require('assert');
2525
const fs = require('fs');
26+
const { COPYFILE_FICLONE } = fs.constants;
2627
const path = require('path');
2728
const tmpdir = require('../common/tmpdir');
2829
const msg = { test: 'this' };
@@ -44,7 +45,7 @@ if (process.env.FORK) {
4445
} catch (e) {
4546
if (e.code !== 'ENOENT') throw e;
4647
}
47-
fs.writeFileSync(copyPath, fs.readFileSync(nodePath));
48+
fs.copyFileSync(nodePath, copyPath, COPYFILE_FICLONE);
4849
fs.chmodSync(copyPath, '0755');
4950

5051
// slow but simple
Collapse file

‎test/parallel/test-module-loading-globalpaths.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-module-loading-globalpaths.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const fixtures = require('../common/fixtures');
44
const assert = require('assert');
55
const path = require('path');
66
const fs = require('fs');
7+
const { COPYFILE_FICLONE } = fs.constants;
78
const child_process = require('child_process');
89
const pkgName = 'foo';
910
const { addLibraryPath } = require('../common/shared-lib-util');
@@ -28,7 +29,7 @@ if (process.argv[2] === 'child') {
2829
testExecPath = path.join(prefixBinPath, path.basename(process.execPath));
2930
}
3031
const mode = fs.statSync(process.execPath).mode;
31-
fs.writeFileSync(testExecPath, fs.readFileSync(process.execPath));
32+
fs.copyFileSync(process.execPath, testExecPath, COPYFILE_FICLONE);
3233
fs.chmodSync(testExecPath, mode);
3334

3435
const runTest = (expectedString, env) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.