@@ -1588,19 +1588,15 @@ then the operation will fail.
15881588
15891589``` js
15901590const fs = require (' fs' );
1591+ const { COPYFILE_EXCL } = fs .constants ;
15911592
1592- // destination.txt will be created or overwritten by default.
1593- fs .copyFile (' source.txt' , ' destination.txt' , (err ) => {
1593+ function callback (err ) {
15941594 if (err) throw err;
15951595 console .log (' source.txt was copied to destination.txt' );
1596- });
1597- ```
1598-
1599- If the third argument is a number, then it specifies ` mode ` :
1596+ }
16001597
1601- ``` js
1602- const fs = require (' fs' );
1603- const { COPYFILE_EXCL } = fs .constants ;
1598+ // destination.txt will be created or overwritten by default.
1599+ fs .copyFile (' source.txt' , ' destination.txt' , callback);
16041600
16051601// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
16061602fs .copyFile (' source.txt' , ' destination.txt' , COPYFILE_EXCL , callback);
@@ -1636,17 +1632,11 @@ then the operation will fail.
16361632
16371633``` js
16381634const fs = require (' fs' );
1635+ const { COPYFILE_EXCL } = fs .constants ;
16391636
16401637// destination.txt will be created or overwritten by default.
16411638fs .copyFileSync (' source.txt' , ' destination.txt' );
16421639console .log (' source.txt was copied to destination.txt' );
1643- ```
1644-
1645- If the third argument is a number, then it specifies ` mode ` :
1646-
1647- ``` js
1648- const fs = require (' fs' );
1649- const { COPYFILE_EXCL } = fs .constants ;
16501640
16511641// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
16521642fs .copyFileSync (' source.txt' , ' destination.txt' , COPYFILE_EXCL );
@@ -4718,20 +4708,17 @@ create a copy-on-write reflink. If the platform does not support copy-on-write,
47184708then the operation will fail.
47194709
47204710``` js
4721- const fsPromises = require (' fs' ).promises ;
4711+ const {
4712+ promises: fsPromises ,
4713+ constants: {
4714+ COPYFILE_EXCL
4715+ }
4716+ } = require (' fs' );
47224717
47234718// destination.txt will be created or overwritten by default.
47244719fsPromises .copyFile (' source.txt' , ' destination.txt' )
47254720 .then (() => console .log (' source.txt was copied to destination.txt' ))
47264721 .catch (() => console .log (' The file could not be copied' ));
4727- ```
4728-
4729- If the third argument is a number, then it specifies ` mode ` :
4730-
4731- ``` js
4732- const fs = require (' fs' );
4733- const fsPromises = fs .promises ;
4734- const { COPYFILE_EXCL } = fs .constants ;
47354722
47364723// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
47374724fsPromises .copyFile (' source.txt' , ' destination.txt' , COPYFILE_EXCL )
0 commit comments