Giter VIP home page Giter VIP logo

Comments (1)

MaciejReszotnik avatar MaciejReszotnik commented on July 21, 2024

I must admit I gave up on powershell and created a simple bash script that does the job. The key thing was using nohup prefix to prevent the process from being terminated once the step on Azure pipeline was complete. I also redirected outputs into null and set the process into background.

If there is a similar way to do this in powershell, I have no idea how to do it.

Anyway, I will share it here so that other people may benefit:

    #!/bin/bash
    # Get root folder of git repo
    rootFolder=$(git rev-parse --show-toplevel)
    
    # Set path to csv file and read it
    echo "Top-level directory: $rootFolder"
    fullPath="$rootFolder/testFiles/csvs/test_csv.csv"
    csv_file=$(cat $fullPath)
    
    # Initialize an empty associative array (dictionary)
    declare -A port_path_dict
    
    # Split the CSV file into lines
    lines=($csv_file)
    
    # Skip the header line
    for ((i=1; i<${#lines[@]}; i++)); do
        # Split each line into port and path
        line="${lines[$i]}"
        IFS=',' read -r port path <<< "$line"
        # Remove quotes from port and path
        port="${port//\"}"
        path="${path//\"}"
        # Add to the dictionary
        port_path_dict["$port"]="$path"
    done
    
    # Iterate over values in the dictionary and start servers
    for port in "${!port_path_dict[@]}"; do
        path=${port_path_dict[$port]}
        # Run mock server but disable terminating it after terminal is closed
        nohup $(npx prism mock -d -p $port ${port_path_dict[$port]}) >/dev/null 2>&1 &
    done

Anyway, I think this issue can be closed.

from prism.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.