MCPcopy Index your code
hub / github.com/isomorphic-git/isomorphic-git / mkdir

Method mkdir

src/models/FileSystem.js:164–184  ·  view source on GitHub ↗

* Make a directory (or series of nested directories) without throwing an error if it already exists. * * @param {string} filepath - The path to the directory. * @param {boolean} [_selfCall=false] - Internal flag to prevent infinite recursion. * @returns {Promise }

(filepath, _selfCall = false)

Source from the content-addressed store, hash-verified

162 * @returns {Promise<void>}
163 */
164 async mkdir(filepath, _selfCall = false) {
165 try {
166 await this._mkdir(filepath)
167 } catch (err) {
168 // If err is null then operation succeeded!
169 if (err === null) return
170 // If the directory already exists, that's OK!
171 if (err.code === 'EEXIST') return
172 // Avoid infinite loops of failure
173 if (_selfCall) throw err
174 // If we got a "no such file or directory error" backup and try again.
175 if (err.code === 'ENOENT') {
176 const parent = dirname(filepath)
177 // Check to see if we've gone too far
178 if (parent === '.' || parent === '/' || parent === filepath) throw err
179 // Infinite recursion, what could go wrong?
180 await this.mkdir(parent)
181 await this.mkdir(filepath, true)
182 }
183 }
184 }
185
186 /**
187 * Delete a file without throwing an error if it is already deleted.

Callers 15

stashFunction · 0.95
writeMethod · 0.95
makeLightningFSFunction · 0.95
makeZenFSFunction · 0.95
applyTreeChangesFunction · 0.80
_checkoutFunction · 0.80
_initFunction · 0.80
test-stash.jsFile · 0.80

Calls 1

dirnameFunction · 0.90

Tested by 2

makeLightningFSFunction · 0.76
makeZenFSFunction · 0.76