MCPcopy
hub / github.com/shelljs/shelljs / writeableDir

Function writeableDir

src/tempdir.js:11–25  ·  view source on GitHub ↗
(dir)

Source from the content-addressed store, hash-verified

9
10// Returns false if 'dir' is not a writeable directory, 'dir' otherwise
11function writeableDir(dir) {
12 if (!dir || !fs.existsSync(dir)) return false;
13
14 if (!common.statFollowLinks(dir).isDirectory()) return false;
15
16 var testFile = dir + '/' + common.randomFileName();
17 try {
18 fs.writeFileSync(testFile, ' ');
19 common.unlinkSync(testFile);
20 return dir;
21 } catch (e) {
22 /* istanbul ignore next */
23 return false;
24 }
25}
26
27// Variable to cache the tempdir value for successive lookups.
28var cachedTempDir;

Callers 1

_tempDirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…