0.2.0 • Published 7 years ago

@parkhub/create-proto-files-paths-map v0.2.0

Weekly downloads
1
License
-
Repository
-
Last release
7 years ago

Create Proto Files Paths Map

Get the full path of protofiles in the nearest protos/ directory in the form of a map keyed by a custom tag of your choosing. Full paths are used by grpc

Install

npm install @parkhub/create-proto-files-paths-map

Use

Sample project directory:

project
└───protos
│   │   proto_file_one.proto
│   │   proto_file_two.proto
└───src
    │   index.js
 // index.js
import createProtoFilesPathsMap from '@parkhub/create-proto-files-paths-map';

const protoFiles = [{
  tag: 'myTag',
  fileName: 'proto_file_one'
}, {
  tag: 'mySecondTag',
  fileName: 'proto_file_two'
}];

createProtoFileMap(protoFiles)
  .then(protoFilesMap => {
    /*
      protoFilesMap is a map with the following properties:
        {
          myTag: /system/path/project/protos/proto_file_one.proto,
          mySecondTag: /system/path/project/protos/proto_file_two.proto,
        }
    */

    const fileOnePath = protoFilesMap.get('myTag');
    const fileTwoPath = protoFilesMap.get('mySecondTag');
  });