fix proto generation script
All checks were successful
Publish NPM Package / Publish Job (push) Successful in 1m42s
All checks were successful
Publish NPM Package / Publish Job (push) Successful in 1m42s
This commit is contained in:
@@ -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 ?? ''}`,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user