web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.4 KiB

  1. # @npmcli/move-file
  2. A fork of [move-file](https://github.com/sindresorhus/move-file) with
  3. compatibility with all node 10.x versions.
  4. > Move a file (or directory)
  5. The built-in
  6. [`fs.rename()`](https://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback)
  7. is just a JavaScript wrapper for the C `rename(2)` function, which doesn't
  8. support moving files across partitions or devices. This module is what you
  9. would have expected `fs.rename()` to be.
  10. ## Highlights
  11. - Promise API.
  12. - Supports moving a file across partitions and devices.
  13. - Optionally prevent overwriting an existing file.
  14. - Creates non-existent destination directories for you.
  15. - Support for Node versions that lack built-in recursive `fs.mkdir()`
  16. - Automatically recurses when source is a directory.
  17. ## Install
  18. ```
  19. $ npm install @npmcli/move-file
  20. ```
  21. ## Usage
  22. ```js
  23. const moveFile = require('@npmcli/move-file');
  24. (async () => {
  25. await moveFile('source/unicorn.png', 'destination/unicorn.png');
  26. console.log('The file has been moved');
  27. })();
  28. ```
  29. ## API
  30. ### moveFile(source, destination, options?)
  31. Returns a `Promise` that resolves when the file has been moved.
  32. ### moveFile.sync(source, destination, options?)
  33. #### source
  34. Type: `string`
  35. File, or directory, you want to move.
  36. #### destination
  37. Type: `string`
  38. Where you want the file or directory moved.
  39. #### options
  40. Type: `object`
  41. ##### overwrite
  42. Type: `boolean`\
  43. Default: `true`
  44. Overwrite existing destination file(s).