Skip to content

Instantly share code, notes, and snippets.

@PoslinskiNet
Created July 2, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PoslinskiNet/8d515a55ca3f1af11b479f6911e96438 to your computer and use it in GitHub Desktop.
Save PoslinskiNet/8d515a55ca3f1af11b479f6911e96438 to your computer and use it in GitHub Desktop.
Ember Electron Read directory service - it fetches list of directories for the given path
import Ember from 'ember';
const fs = requireNode('fs')
const path = requireNode('path')
export default Ember.Service.extend({
/**
* Get list of the directories for the given path
* @param {String} absolutePath absolute path
* @return {Array} List of directories in the given path
*/
getDirectories(absolutePath) {
return fs.readdirSync(absolutePath)
.filter(file => fs.lstatSync(path.join(absolutePath, file)).isDirectory());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment