Skip to content

amiroous/javascript-file-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Mapper Module

Map directory file structure and generate a report as a JSON file

The module will receive 3 arguments as config:

  • PATH_TO_BE_MAPPED : Folder path to be mapped

  • IGNORE_FILES_FOLDERS_LIST : Array of filenames with extension and/or folder names to be excluded.

  • FILE_TO_GENERATE : Path and filename (with extension) which map report will be generated into it.

If you don't have any ignore list but wanna specify generated file, you need to pass null as second argument.

Usage:

Install file-mapper Module
- in `ems/turbotax/src/main/package.json` add following code as `devDependencies`
    - `"file-mapper": "git+https://github.intuit.com/TTcom/file-mapper.git#v1.0.1",` (check the latest release version)
- Through terminal make sure you're in `ems/turbotax/src/main` and run `npm install`
Use it in JS File:
let fileMapper = require('file-mapper');

fileMapper(_PATH_TO_BE_MAPPED_, _IGNORE_FILES_FOLDERS_LIST_, _FILE_TO_GENERATE_)
    .then(function(fileMap) {
        // Do what need to be done with fileMap object
        console.log(fileMap);
    });
Use it through Gruntfile:
grunt.registerTask('ems-file-mapper', 'Generate a map structure of given folder', function(report) {
        let done = this.async();
        let fileMapper = require('file-mapper');
        let folderToMap = 'webapp/handlebars/';
        let excludes = JSON.parse(grunt.file.read('ems-file-mapper-exclusion.json')).excludes || {};
        report = report || 'ems-file-mapper-report.json';
        fileMapper(folderToMap, excludes, report).then(() => done());
    });
  • Run ems-file-mapper manually or add it into other commands like build
Examples:
- without any ignored folder list `fileMapper(__dirname + '/handlebars/');`
- with ignored list `fileMapper(__dirname + '/handlebars/' , ['mktg-tests', 'ignorfile.iml']);`
- with generated file path `fileMapper(__dirname + '/handlebars/' , ['mktg-tests'], __dirname +'/my-folder/report.json');` (my-folder should be existed)

Available Commands:

  • npm test Runs all the tests written in test/map-structure.test.js and report in terminal.

  • npm run bump Bump a new version (in package.json) and add related tag for release. Make sure before bumping new version, git pull origin master and after bumping git push origin master

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published