Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer script section os.dependent

Is it possible to check for the current operating system? The following cmd fails on windows, because chmod does not exist

{ ...
  "scripts": {
    "post-update-cmd": "chmod -R 777 ../log"
  }
}

Is there a workaround to solve this ? Kind regards, Robert

like image 259
derRobert Avatar asked Apr 05 '26 18:04

derRobert


1 Answers

Simplest solution is using PHP itself I reckon:

{ ...
  "scripts": {
    "post-update-cmd": "php -r chmod('../log', 0777);"
  }
}

This requires the php binary to be in your PATH (or similar) on Linux/OSX/Windows.

Ps: I can't recall for sure, but I believe path should be relative to where your composer.json is, so you may have to adjust the above path accordingly.

like image 66
alcohol Avatar answered Apr 08 '26 09:04

alcohol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!