From b86057dfcf6e9c2339579fb1a19a173d4be8a530 Mon Sep 17 00:00:00 2001 From: lendry Date: Thu, 21 May 2026 22:07:48 +0300 Subject: [PATCH] fix proto generation script --- scripts/generate-proto.mjs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/generate-proto.mjs b/scripts/generate-proto.mjs index 9cf58ec..3089dfe 100644 --- a/scripts/generate-proto.mjs +++ b/scripts/generate-proto.mjs @@ -13,6 +13,14 @@ const rootDir = process.cwd() const protoRoot = 'proto' const genRoot = 'gen' +const isWindows = process.platform === 'win32' + +const tsProtoBinDir = join(rootDir, 'node_modules', '.bin') + +const tsProtoPlugin = isWindows + ? join(tsProtoBinDir, 'protoc-gen-ts_proto.cmd') + : join(tsProtoBinDir, 'protoc-gen-ts_proto') + function toUnixPath(path) { return path.replaceAll('\\', '/') } @@ -42,11 +50,8 @@ if (!existsSync(protoRoot)) { process.exit(1) } -const tsProtoBinDir = join('node_modules', '.bin') -const tsProtoCmd = join(tsProtoBinDir, 'protoc-gen-ts_proto.cmd') - -if (!existsSync(tsProtoCmd)) { - console.error('ts-proto plugin not found.') +if (!existsSync(tsProtoPlugin)) { + console.error(`ts-proto plugin not found: ${tsProtoPlugin}`) console.error('Run: yarn add -D ts-proto') process.exit(1) } @@ -69,8 +74,6 @@ mkdirSync(genRoot, { const env = { ...process.env, - - // Windows обычно использует Path, Linux/macOS используют PATH. PATH: `${tsProtoBinDir}${delimiter}${process.env.PATH ?? ''}`, Path: `${tsProtoBinDir}${delimiter}${process.env.Path ?? ''}`, }