ipc.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.serializeConfig = serializeConfig;
  6. exports.stdioChunkToParams = stdioChunkToParams;
  7. var _util = _interopRequireDefault(require("util"));
  8. var _compilationCache = require("../transform/compilationCache");
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. /**
  11. * Copyright Microsoft Corporation. All rights reserved.
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License");
  14. * you may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. function serializeConfig(config) {
  26. const result = {
  27. configFile: config.config.configFile,
  28. configDir: config.configDir,
  29. configCLIOverrides: config.configCLIOverrides,
  30. compilationCache: (0, _compilationCache.serializeCompilationCache)()
  31. };
  32. return result;
  33. }
  34. function stdioChunkToParams(chunk) {
  35. if (chunk instanceof Uint8Array) return {
  36. buffer: Buffer.from(chunk).toString('base64')
  37. };
  38. if (typeof chunk !== 'string') return {
  39. text: _util.default.inspect(chunk)
  40. };
  41. return {
  42. text: chunk
  43. };
  44. }