diff --git a/bulletin-board-server-frontend/generate-protobuf.js b/bulletin-board-server-frontend/generate-protobuf.js index eeb255e..57332d8 100755 --- a/bulletin-board-server-frontend/generate-protobuf.js +++ b/bulletin-board-server-frontend/generate-protobuf.js @@ -1,15 +1,26 @@ #!/usr/bin/env node const { execFileSync } = require('child_process'); +const path = require('path'); + +const isWin = (process.platform === 'win32'); const bundlejs = 'src/app/bundle.js' const bundlets = 'src/app/bundle.d.ts' +const npm = isWin ? 'npm.cmd' : 'npm'; + + +var args = process.argv.slice(2).map(function(x) { + return path.normalize(x); +}); + + var pbjs_args = [ '-t', 'static-module', '-w', 'commonjs', '-o', bundlejs -].concat(process.argv.slice(2)); +].concat(args); console.log("Running pbjs " + pbjs_args.join(" ")); -var out = execFileSync('pbjs', pbjs_args); +var out = execFileSync(npm, ['run', 'pbjs', '--'].concat(pbjs_args)); console.log("" + out); var pbts_args = [ @@ -17,5 +28,5 @@ var pbts_args = [ ]; console.log("Running pbts " + pbts_args.join(" ")); -out = execFileSync('pbts', pbts_args); +out = execFileSync(npm, ['run', 'pbts', '--'].concat(pbts_args)); console.log("" + out); diff --git a/bulletin-board-server-frontend/package.json b/bulletin-board-server-frontend/package.json index 58d7e8a..8388fa4 100644 --- a/bulletin-board-server-frontend/package.json +++ b/bulletin-board-server-frontend/package.json @@ -10,7 +10,7 @@ "lint": "ng e2e", "pbts": "pbts", "pbjs": "pbjs", - "protoc" : "./generate-protobuf.js" + "protoc" : "node ./generate-protobuf.js" }, "private": true, "dependencies": {