How to use the builder-util-runtime.safeStringifyJson function in builder-util-runtime

To help you get started, we’ve selected a few builder-util-runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-builder / packages / app-builder-lib / src / ProtonFramework.ts View on Github external
if (process.env.TEST_SET_BABEL_PRESET === "true") {
      babel = require("@babel/core")
      babel = testOnlyBabel(babel, babelOptions, this.version)
    }
    else {
      try {
        babel = require("babel-core")
      }
      catch (e) {
        // babel isn't installed
        log.debug(null, "don't transpile source code using Babel")
        return null
      }
    }

    log.info({options: safeStringifyJson(babelOptions, new Set(["presets"]))}, "transpile source code using Babel")
    return file => {
      if (!(file.endsWith(".js") || file.endsWith(".jsx")) || file.includes(NODE_MODULES_PATTERN)) {
        return null
      }

      return new Promise((resolve, reject) => {
        return babel.transformFile(file, babelOptions, (error: Error, result: any) => {
          if (error == null) {
            resolve(result.code)
          }
          else {
            reject(error)
          }
        })
      })
    }
github electron-userland / electron-builder / packages / electron-updater / src / MacUpdater.ts View on Github external
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise> {
    this.updateInfoForPendingUpdateDownloadedEvent = null

    const files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)
    const zipFileInfo = findFile(files, "zip", ["pkg", "dmg"])
    if (zipFileInfo == null) {
      throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, "ERR_UPDATER_ZIP_FILE_NOT_FOUND")
    }

    const server = createServer()
    server.on("close", () => {
      this._logger.info(`Proxy server for native Squirrel.Mac is closed (was started to download ${zipFileInfo.url.href})`)
    })

    function getServerUrl() {
      const address = server.address() as AddressInfo
      return `http://127.0.0.1:${address.port}`
    }

    return this.executeDownload({
      fileExtension: "zip",
      fileInfo: zipFileInfo,
      downloadUpdateOptions,
github electron-userland / electron-builder / packages / builder-util / src / util.ts View on Github external
file,
      args: args == null ? "" : removePassword(args.join(" ")),
    }
    if (options != null) {
      if (options.cwd != null) {
        logFields.cwd = options.cwd
      }

      if (options.env != null) {
        const diffEnv = {...options.env}
        for (const name of Object.keys(process.env)) {
          if (process.env[name] === options.env[name]) {
            delete diffEnv[name]
          }
        }
        logFields.env = safeStringifyJson(diffEnv)
      }
    }

    log.debug(logFields, "executing")
  }

  return new Promise((resolve, reject) => {
    execFile(file, args, {
    ...options,
    maxBuffer: 1000 * 1024 * 1024,
    env: getProcessEnv(options == null ? null : options.env),
  }, (error, stdout, stderr) => {
      if (error == null) {
        if (isLogOutIfDebug && log.isDebugEnabled) {
          const logFields: any = {
            file,