Skip to content

Commit

Permalink
Pass --proto_path to protoc (#127)
Browse files Browse the repository at this point in the history
This is necessary when passing a relative path outside the current
working directory to `--protocol-path`.
  • Loading branch information
nex3 committed Apr 8, 2022
1 parent 492295b commit 464d9d5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tool/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://opensource.org/licenses/MIT.

import extractZip = require('extract-zip');
import {promises as fs, existsSync} from 'fs';
import {promises as fs, existsSync, mkdirSync} from 'fs';
import fetch from 'node-fetch';
import * as p from 'path';
import * as shell from 'shelljs';
Expand Down Expand Up @@ -98,7 +98,7 @@ export async function getEmbeddedProtocol(
const source =
options && 'path' in options ? options.path : p.join(BUILD_PATH, repo);
buildEmbeddedProtocol(source);
await link(source, p.join(outPath, repo));
await link('build/embedded-protocol', p.join(outPath, repo));
}

/**
Expand Down Expand Up @@ -257,11 +257,13 @@ function buildEmbeddedProtocol(repoPath: string): void {
OS === 'windows'
? '%CD%/node_modules/.bin/protoc-gen-ts.cmd'
: 'node_modules/.bin/protoc-gen-ts';
mkdirSync('build/embedded-protocol', {recursive: true});
shell.exec(
`${protocPath} \
--plugin="protoc-gen-ts=${pluginPath}" \
--js_out="import_style=commonjs,binary:." \
--ts_out="." \
--js_out="import_style=commonjs,binary:build/embedded-protocol" \
--ts_out="build/embedded-protocol" \
--proto_path="${repoPath}" \
${proto}`,
{silent: true}
);
Expand Down

0 comments on commit 464d9d5

Please sign in to comment.