lib/locate-file.js
function getBasePath(base) {
	return new Promise((resolve, reject) => {
		if (base && typeof base.getPath === 'function') {
			const editorFile = base.getPath();
			if (!editorFile) {
				return reject(new Error('Unable to get base path: editor contains unsaved file'));
			}

			base = path.dirname(editorFile);
		}

		if (!base || typeof base !== 'string') {
			reject(new Error(`Unable to get base path from ${base}`));
		} else {
			resolve(base);
		}
	});
}
function getBasePath(base) {
	return new Promise((resolve, reject) => {
		if (base && typeof base.getPath === 'function') {
			const editorFile = base.getPath();
			if (!editorFile) {
				return reject(new Error('Unable to get base path: editor contains unsaved file'));
			}

			base = path.dirname(editorFile);
		}

		if (!base || typeof base !== 'string') {
			reject(new Error(`Unable to get base path from ${base}`));
		} else {
			resolve(base);
		}
	});
}
function getBasePath ( base ) { return new Promise ( ( resolve , reject ) => { if ( base && typeof base . getPath === 'function' ) { const editorFile = base . getPath ( ) ; if ( ! editorFile ) { return reject ( new Error ( 'Unable to get base path: editor contains unsaved file' ) ) ; } base = path . dirname ( editorFile ) ; } if ( ! base || typeof base !== 'string' ) { reject ( new Error ( ` ${ base } ` ) ) ; } else { resolve ( base ) ; } } ) ; }
Returns base path from file, opened in given editor
@param  {TextEditor|String} base
@return {Promise}
Returns base path from file opened in given editor