1

I have a package.json like this:

...
  "scripts": {
    "dev": "webpack --config webpack.dev.config.js --mode development --progress --colors",
    "postdev": "if (Test-Path \"./postdev.sh\" ) { echo \"file exists\"; ./postdev.sh }"
  },
...

How can I check if file "postdev.sh" exists and then launch it in NPM-scripts section? I run that command in the terminal and it goes correctly, but if I try to launch that npm-script it says "Unexpected appearance: "./postdev.sh"."

G. Goncharov
  • 133
  • 1
  • 11
  • Solution found here: https://stackoverflow.com/questions/4340350/how-to-check-if-a-file-exists-from-inside-a-batch-file – G. Goncharov Sep 24 '21 at 06:09

2 Answers2

1

on macos or linux try this one for postdev:

"postdev": "test -f ./postdev.sh && echo 'file exisits' && ./postdev.sh",
Dmitriy Ievlev
  • 171
  • 2
  • 5
0

Finnally found a solution (maybe it works only on Windows, but it is enough for me):

"postdev": "if exist postdev.sh ( postdev.sh )",
G. Goncharov
  • 133
  • 1
  • 11