• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript child_process.execFileSync函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中child_process.execFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript execFileSync函数的具体用法?TypeScript execFileSync怎么用?TypeScript execFileSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了execFileSync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: terminate

export function terminate(process: ChildProcess, cwd?: string): boolean {
  if (isWindows) {
    try {
      // This we run in Atom execFileSync is available.
      // Ignore stderr since this is otherwise piped to parent.stderr
      // which might be already closed.
      let options: any = {
        stdio: ['pipe', 'pipe', 'ignore']
      }
      if (cwd) {
        options.cwd = cwd
      }
      cp.execFileSync(
        'taskkill',
        ['/T', '/F', '/PID', process.pid.toString()],
        options
      )
      return true
    } catch (err) {
      return false
    }
  } else if (isLinux || isMacintosh) {
    try {
      let cmd = join(pluginRoot, 'bin/terminateProcess.sh')
      let result = cp.spawnSync(cmd, [process.pid.toString()])
      return result.error ? false : true
    } catch (err) {
      return false
    }
  } else {
    process.kill('SIGKILL')
    return true
  }
}
开发者ID:illarionvk,项目名称:dotfiles,代码行数:34,代码来源:processes.ts


示例2: xdotool

function xdotool(text: string): void {
	try {
		execFileSync('xdotool', text.split(/ /));
	} catch (err) {
		process.stderr.write(`xdotool process terminated with error: ${err}\n`);
	}
}
开发者ID:andre-luiz-dos-santos,项目名称:mwpc,代码行数:7,代码来源:type.ts


示例3: runCode

export function runCode(argv: any) {
  // run code in temp path, and cleanup
  var temp = require('temp')
  temp.track()
  process.on('SIGINT',  () => temp.cleanupSync())
  process.on('SIGTERM', () => temp.cleanupSync())

  let tempPath = temp.mkdirSync('tsrun')
  let outDir = tempPath
  if (argv.o) {
    outDir = path.join(tempPath, argv.o)
  }
  let compileError = compile(argv._, {
      outDir,
      noEmitOnError: true,
      target: ts.ScriptTarget.ES5,
      module: ts.ModuleKind.CommonJS,
      experimentalDecorators: true,
  })
  if (compileError) process.exit(compileError)
  linkDir(process.cwd(), tempPath)
  // slice argv. 0: node, 1: tsun binary 2: arg
  var newArgv = process.argv.slice(2).map(arg => {
    if (!/\.ts$/.test(arg)) return arg
    return path.join(outDir, arg.replace(/ts$/, 'js'))
  })
  child_process.execFileSync('node', newArgv, {
    stdio: 'inherit'
  })
  process.exit()
}
开发者ID:joelbinn,项目名称:typescript-repl,代码行数:31,代码来源:executor.ts


示例4: openGateway

  private async openGateway({id, config}: SerialGateway) {
    const serialPort = config.serialPort
    execFileSync('stty', ['-F', serialPort, gwBaud.toString()])
    let port: SerialPort
    let errors = 0

    const open = async () => {
      port = await serialjs.open(serialPort, '\n')
      this.log.info(`connected to serial gateway at ${serialPort}`)
      serialPorts[id] = port
      return port
    }

    port = await open()

    port.on('end', () => {
      this.log.info(`disconnected from gateway at ${serialPort}`)
      delete serialPorts[id]
    })

    port.on('data', rd => {
      this.receivedMessage(id, rd)
    })

    port.on('error', () => {
      this.log.error(`connection error - trying to reconnect to ${serialPort}`)

      setTimeout(() => {
        open()
      }, errors ** 2 * 1000)
      errors++
    })
  }
开发者ID:Pajn,项目名称:RAXA,代码行数:33,代码来源:index.ts


示例5: resetSystemProxy

// Configures the system to no longer use our proxy.
function resetSystemProxy() {
  console.log(`resetting system proxy`);
  try {
    execFileSync(pathToEmbeddedExe('setsystemproxy'), ['off']);
  } catch (e) {
    throw new Error(`could not reset system proxy: ${e.stderr}`);
  }
}
开发者ID:fang2x,项目名称:outline-client,代码行数:9,代码来源:process_manager.ts


示例6: pdf

async function pdf(fullPath: string): Promise<string> {
  const binExt = { darwin: 'osx', linux: 'linux', win32: 'win.exe' }[os.platform()]
  const args = ['-enc', 'UTF-8', fullPath, '-']

  return execFileSync(path.resolve(__dirname, './tools/bin/pdftotext_' + binExt), args, {
    encoding: 'utf8'
  })
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:8,代码来源:converters.ts


示例7: configureSystemProxy

// Configures the system to use our proxy.
// TODO: Make some effort to backup and restore the system proxy settings.
function configureSystemProxy(httpProxyPort: number) {
  try {
    execFileSync(
        pathToEmbeddedExe('setsystemproxy'), ['on', `${PROXY_IP}:${httpProxyPort}`],
        {timeout: 1500});
  } catch (e) {
    throw new Error(`could not configure system proxy: ${e.stderr}`);
  }
}
开发者ID:fang2x,项目名称:outline-client,代码行数:11,代码来源:process_manager.ts


示例8: isValidPythonPath

function isValidPythonPath(pythonPath): boolean {
    try {
        let output = child_process.execFileSync(pythonPath, ['-c', 'print(1234)'], { encoding: 'utf8' });
        return output.startsWith('1234');
    }
    catch (ex) {
        return false;
    }
}
开发者ID:,项目名称:,代码行数:9,代码来源:


示例9: setTimeout

	closeTimeout = setTimeout(function () {
		if (process.platform === 'win32') {
			// Forcefully kill the entire process tree under the shell process
			// on Windows as ptyProcess.kill can leave some lingering processes.
			// See https://github.com/Microsoft/vscode/issues/26807
			cp.execFileSync('taskkill.exe', ['/T', '/F', '/PID', ptyProcess.pid.toString()]);
		}
		ptyProcess.kill();
		process.exit(exitCode);
	}, 250);
开发者ID:,项目名称:,代码行数:10,代码来源:


示例10: resolve

    }, (error, stdout, stderr) => {
      if (error != null || stderr) {
        if (isOldWin6()) {
          logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error || stderr}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`)
          resolve(null)
          return
        }

        try {
          execFileSync("powershell.exe", ["ConvertTo-Json test"], {timeout: 10 * 1000})
        }
        catch (testError) {
          logger.warn(`Cannot execute ConvertTo-Json: ${testError.message}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`)
          resolve(null)
          return
        }

        if (error != null) {
          reject(error)
          return
        }

        if (stderr) {
          reject(new Error(`Cannot execute Get-AuthenticodeSignature: ${stderr}`))
          return
        }
      }

      const data = JSON.parse(stdout)
      delete data.PrivateKey
      delete data.IsOSBinary
      delete data.SignatureType
      const signerCertificate = data.SignerCertificate
      if (signerCertificate != null) {
        delete signerCertificate.Archived
        delete signerCertificate.Extensions
        delete signerCertificate.Handle
        delete signerCertificate.HasPrivateKey
        // duplicates data.SignerCertificate (contains RawData)
        delete signerCertificate.SubjectName
      }
      delete data.Path

      if (data.Status === 0) {
        const name = parseDn(data.SignerCertificate.Subject).get("CN")!
        if (publisherNames.includes(name)) {
          resolve(null)
          return
        }
      }

      const result = `publisherNames: ${publisherNames.join(" | ")}, raw info: ` + JSON.stringify(data, (name, value) => name === "RawData" ? undefined : value, 2)
      logger.info(`Sign verification failed, installer signed with incorrect certificate: ${result}`)
      resolve(result)
    })
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:55,代码来源:windowsExecutableCodeSignatureVerifier.ts



注:本文中的child_process.execFileSync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript child_process.execSync函数代码示例发布时间:2022-05-24
下一篇:
TypeScript child_process.execFile函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap