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.

ensureLink.md 636 B

3 years ago
1234567891011121314151617181920212223242526272829
  1. # ensureLink(srcpath, dstpath, [callback])
  2. Ensures that the link exists. If the directory structure does not exist, it is created.
  3. - `srcpath` `<String>`
  4. - `dstpath` `<String>`
  5. - `callback` `<Function>`
  6. ## Example:
  7. ```js
  8. const fs = require('fs-extra')
  9. const srcpath = '/tmp/file.txt'
  10. const dstpath = '/tmp/this/path/does/not/exist/file.txt'
  11. fs.ensureLink(srcpath, dstpath, err => {
  12. console.log(err) // => null
  13. // link has now been created, including the directory it is to be placed in
  14. })
  15. // With Promises:
  16. fs.ensureLink(srcpath, dstpath)
  17. .then(() => {
  18. console.log('success!')
  19. })
  20. .catch(err => {
  21. console.error(err)
  22. })
  23. ```