xref: /third_party/node/deps/npm/node_modules/mkdirp/lib/find-made.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/deps/npm/node_modules/mkdirp/lib/
11cb0ef41Sopenharmony_ciconst {dirname} = require('path')
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst findMade = (opts, parent, path = undefined) => {
41cb0ef41Sopenharmony_ci  // we never want the 'made' return value to be a root directory
51cb0ef41Sopenharmony_ci  if (path === parent)
61cb0ef41Sopenharmony_ci    return Promise.resolve()
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci  return opts.statAsync(parent).then(
91cb0ef41Sopenharmony_ci    st => st.isDirectory() ? path : undefined, // will fail later
101cb0ef41Sopenharmony_ci    er => er.code === 'ENOENT'
111cb0ef41Sopenharmony_ci      ? findMade(opts, dirname(parent), parent)
121cb0ef41Sopenharmony_ci      : undefined
131cb0ef41Sopenharmony_ci  )
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconst findMadeSync = (opts, parent, path = undefined) => {
171cb0ef41Sopenharmony_ci  if (path === parent)
181cb0ef41Sopenharmony_ci    return undefined
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  try {
211cb0ef41Sopenharmony_ci    return opts.statSync(parent).isDirectory() ? path : undefined
221cb0ef41Sopenharmony_ci  } catch (er) {
231cb0ef41Sopenharmony_ci    return er.code === 'ENOENT'
241cb0ef41Sopenharmony_ci      ? findMadeSync(opts, dirname(parent), parent)
251cb0ef41Sopenharmony_ci      : undefined
261cb0ef41Sopenharmony_ci  }
271cb0ef41Sopenharmony_ci}
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_cimodule.exports = {findMade, findMadeSync}
30

Indexes created Thu Nov 07 10:32:03 CST 2024