danilr2020-10-22 11:31:53
danilr, 2020-10-22 11:31:53

How to rewrite a line of code for Windows?

There is a console command in package.json that generates a new file using npm packages (but that doesn't matter).
On macOS, this command runs and executes, but not on Windows. I believe that this is due to the different syntax in Windows and Mac.
How to rewrite this script for windows?
There are two commands:

"scripts": {
    "process-all-swaggers": "for f in ./swagger/*; do FILE=$f npm run process-swagger; done",
    "process-swagger": "name=$(basename ${FILE%.*}); nameup=`echo $name | awk -F - '{for(i=1; i<=NF; i++) printf \"%s\", toupper(substr($i,1,1)) substr($i,2);}'`; npx nswag swagger2tsclient /Template:Fetch /TypeStyle:Interface /ClassName:$nameup /Input:$FILE /GenerateOptionalParameters:true /TemplateDirectory:./node_modules/mmmm/lib/nswag/ef /Output:./trash/nswag/api.ts && tslint --config ./tslint.json ./src/data/api/$name/index.ts --fix",

PS Dumb, the problem is in the first line of each script

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Saboteur, 2020-10-22

There is a problem in every line of the script.
Your commands are written not for Mac, but for nodesj and bash, which by default is not in Windows at all.
Rewriting these couple of commands can take forever, especially considering that you use various awk, tslint, npm
Do you have at least nodejs installed on Windows? Works?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question