Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

find-made.js 763B

1234567891011121314151617181920212223242526272829
  1. const {dirname} = require('path')
  2. const findMade = (opts, parent, path = undefined) => {
  3. // we never want the 'made' return value to be a root directory
  4. if (path === parent)
  5. return Promise.resolve()
  6. return opts.statAsync(parent).then(
  7. st => st.isDirectory() ? path : undefined, // will fail later
  8. er => er.code === 'ENOENT'
  9. ? findMade(opts, dirname(parent), parent)
  10. : undefined
  11. )
  12. }
  13. const findMadeSync = (opts, parent, path = undefined) => {
  14. if (path === parent)
  15. return undefined
  16. try {
  17. return opts.statSync(parent).isDirectory() ? path : undefined
  18. } catch (er) {
  19. return er.code === 'ENOENT'
  20. ? findMadeSync(opts, dirname(parent), parent)
  21. : undefined
  22. }
  23. }
  24. module.exports = {findMade, findMadeSync}