Skip to content

Commit

Permalink
refactor: use walkdir instead of globby (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Nov 9, 2018
1 parent 9a23d42 commit 7849ea3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"pretest": "npm run prepare && npm run compile"
},
"dependencies": {
"globby": "^8.0.0",
"protobufjs": "^6.8.0"
"protobufjs": "^6.8.0",
"walkdir": "0.0.12"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^2.1.4",
Expand Down
18 changes: 10 additions & 8 deletions src/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

import * as globby from 'globby';
import * as path from 'path';
import * as protobuf from 'protobufjs';
import * as walk from 'walkdir';

let COMMON_PROTO_FILES;
let COMMON_PROTO_FILES: string[];

export interface GoogleProtoFilesRootOptions {
// tslint:disable-next-line no-any
Expand All @@ -34,14 +34,16 @@ export class GoogleProtoFilesRoot extends protobuf.Root {
// on.
'rpc',
'type',
];

const commonProtoGlobPatterns = commonProtoDirs.map(
dir => path.join(__dirname, '../../', 'google', dir, '**', '*.proto'));
].map(dir => path.join(__dirname, '../../', 'google', dir));

if (!COMMON_PROTO_FILES) {
COMMON_PROTO_FILES =
globby.sync(commonProtoGlobPatterns).map(path.normalize);
COMMON_PROTO_FILES = commonProtoDirs
.map(dir => {
return (walk.sync(dir) as string[])
.filter(f => path.extname(f) === '.proto')
.map(path.normalize);
})
.reduce((a, c) => a.concat(c), []);
}

return COMMON_PROTO_FILES;
Expand Down

0 comments on commit 7849ea3

Please sign in to comment.