fix proto generation script
All checks were successful
Publish NPM Package / Publish Job (push) Successful in 1m42s

This commit is contained in:
lendry
2026-05-21 22:07:48 +03:00
parent 5075c37e5e
commit b86057dfcf

View File

@@ -13,6 +13,14 @@ const rootDir = process.cwd()
const protoRoot = 'proto' const protoRoot = 'proto'
const genRoot = 'gen' 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) { function toUnixPath(path) {
return path.replaceAll('\\', '/') return path.replaceAll('\\', '/')
} }
@@ -42,11 +50,8 @@ if (!existsSync(protoRoot)) {
process.exit(1) process.exit(1)
} }
const tsProtoBinDir = join('node_modules', '.bin') if (!existsSync(tsProtoPlugin)) {
const tsProtoCmd = join(tsProtoBinDir, 'protoc-gen-ts_proto.cmd') console.error(`ts-proto plugin not found: ${tsProtoPlugin}`)
if (!existsSync(tsProtoCmd)) {
console.error('ts-proto plugin not found.')
console.error('Run: yarn add -D ts-proto') console.error('Run: yarn add -D ts-proto')
process.exit(1) process.exit(1)
} }
@@ -69,8 +74,6 @@ mkdirSync(genRoot, {
const env = { const env = {
...process.env, ...process.env,
// Windows обычно использует Path, Linux/macOS используют PATH.
PATH: `${tsProtoBinDir}${delimiter}${process.env.PATH ?? ''}`, PATH: `${tsProtoBinDir}${delimiter}${process.env.PATH ?? ''}`,
Path: `${tsProtoBinDir}${delimiter}${process.env.Path ?? ''}`, Path: `${tsProtoBinDir}${delimiter}${process.env.Path ?? ''}`,
} }