当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript child_process.execFileSync函数代码示例

本文整理汇总了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;未经允许,请勿转载。