A ampersand.js set of classes to help files and directories handling.
npm install files-collectionA Ampersand.js set of classes to provide tools
to browse and manage files and directories (existing or not).
Originally written for grunt-gtfd,
a grunt.js task to generate project wide documentation.
``js
var FilesCollection = require('files-collection');
var filesCollection = new FilesCollection([
{ filepath: 'index.js' },
{ filepath: 'fictive/filepath/scripts.js' },
{ filepath: 'fictive/filepath/styles.less' },
{ filepath: 'fictive/index.js' },
{ filepath: 'fictive/other-filepath/index' },
{ filepath: 'fictive/other-filepath/styles.less' }
]);
var autogeneratedDirectory = filesCollection.get('fictive');
autogeneratedDirectory.dirname // ==> '.'
autogeneratedDirectory.basename // ==> 'fictive'
autogeneratedDirectory.isDir // ==> true
autogeneratedDirectory.isRootDir // ==> false
autogeneratedDirectory.files // ==> a collection with the files and directories
var scriptFile = filesCollection.get('fictive/filepath/scripts.js');
scriptFile.dirname // ==> 'fictive/filepath'
scriptFile.basename // ==> 'scripts.js'
scriptFile.isDir // ==> false
scriptFile.relative('fictive/index.js') // ==> '../index.js'
`
Can be generated using npm run-script docs and will be written in DOCUMENTATION.md.
Can be runned usin npm test`.
Valentin Vago @zeropaper valentin.vago@gmail.com