从powershell启动非阻塞过程

时间:2012-05-17 16:27:32

标签: git powershell asynchronous nonblocking

我正在编写一个PowerShell脚本,需要同时将代码推送到几个git存储库吗?

这是我到目前为止的脚本:

param(
    [parameter(Mandatory=$true)]
    [string]$repoPath,
    [parameter(Mandatory=$true)]
    [array]$remoteRepos
)

pushd $repoPath
$remoteRepos | % { 
    #Want to exexcute this without blocking
    & git push $_ master --fore -v 
}
popd

以下是我执行脚本的方法:

gitdeploy.ps1 -repoPath c:\code\myrepo -remoteRepos repo1,repo2

如何以非阻塞的方式执行& git push $_ master --fore -v

感谢@Jamey的解决方案。我执行了这个命令:

Start-Process "cmd.exe" "/c git push $_ master --force -v"

3 个答案:

答案 0 :(得分:7)

您还可以使用start-process在其他命令窗口中运行每次推送。

start-process -FilePath "git" -ArgumentList ("push", $_,  "master", "--fore", "-v") 

答案 1 :(得分:2)

Micah,你可以使用start-job在后台运行它 - http://technet.microsoft.com/en-us/library/dd347692.aspx

答案 2 :(得分:0)

import React,{useState,useEffect} from 'react'; import './App.css'; import { CharacterComponent } from "../src/CharacterComponent" import axios from "axios" import ReactDOM from "react-dom"; export const Characters = () => { // Try to think through what state you'll need for this app before starting. Then build out // the state properties here. // Fetch characters from the star wars api in an effect hook. Remember, anytime you have a // side effect in a component, you want to think about which state and/or props it should // sync up with, if any. const [character,setCharacter] = useState({}) useEffect( () => { axios.get("https://swapi.co/api/people") .then(res => setCharacter(res.data.results) ) },[]) (console.log(character)) return ( <> <div> {character.map((element,index) => <CharacterComponent id={element} key={index} />)} </div> </> ) }