lib/logger.js
function isWritable(dir) {
	debug('checking if ' + dir + ' is writable');
	try {
		if (!fs.existsSync(dir)) {
			debug(' - it does not exist yet, attempting to create it');
			fs.mkdirSync(dir);
		}
		if (fs.accessSync) {
			fs.accessSync(dir, fs.W_OK);
		} else {
			debug(' - fs.accessSync is not available, falling back to manual write detection');
			fs.writeFileSync(path.join(dir, '.foo'), 'foo');
			assert.equal(fs.readFileSync(path.join(dir, '.foo'), 'UTF-8'), 'foo');
			fs.unlinkSync(path.join(dir, '.foo'));
		}
		debug(' - yes, it is writable');
		return true;
	} catch (exc) {
		debug(' - no, it is not writable: ', exc);
		return false;
	}
}
function isWritable(dir) {
	debug('checking if ' + dir + ' is writable');
	try {
		if (!fs.existsSync(dir)) {
			debug(' - it does not exist yet, attempting to create it');
			fs.mkdirSync(dir);
		}
		if (fs.accessSync) {
			fs.accessSync(dir, fs.W_OK);
		} else {
			debug(' - fs.accessSync is not available, falling back to manual write detection');
			fs.writeFileSync(path.join(dir, '.foo'), 'foo');
			assert.equal(fs.readFileSync(path.join(dir, '.foo'), 'UTF-8'), 'foo');
			fs.unlinkSync(path.join(dir, '.foo'));
		}
		debug(' - yes, it is writable');
		return true;
	} catch (exc) {
		debug(' - no, it is not writable: ', exc);
		return false;
	}
}
function isWritable ( dir ) { debug ( 'checking if ' + dir + ' is writable' ) ; try { if ( ! fs . existsSync ( dir ) ) { debug ( ' - it does not exist yet, attempting to create it' ) ; fs . mkdirSync ( dir ) ; } if ( fs . accessSync ) { fs . accessSync ( dir , fs . W_OK ) ; } else { debug ( ' - fs.accessSync is not available, falling back to manual write detection' ) ; fs . writeFileSync ( path . join ( dir , '.foo' ) , 'foo' ) ; assert . equal ( fs . readFileSync ( path . join ( dir , '.foo' ) , 'UTF-8' ) , 'foo' ) ; fs . unlinkSync ( path . join ( dir , '.foo' ) ) ; } debug ( ' - yes, it is writable' ) ; return true ; } catch ( exc ) { debug ( ' - no, it is not writable: ' , exc ) ; return false ; } }
istanbul ignore next 
Checks if a directory is writable, returning a boolean or throwing an exception, depending on the arguments.
@param {string} dir The directory to check.
@returns {boolean} Whether or not the directory is writable.
istanbul ignore next Checks if a directory is writable returning a boolean or throwing an exception depending on the arguments .