Hi,
I've started to use prettier-php so I've followed the README example. When I run from my ubuntu 16 cli prettier --write ... I get an error Command not found as the library is installed locally.
I've tried with ./node_modules/.bin/prettier --write ... and then it works. Would it be better to use as a global cli tool, so prettier would be available ?
Also, after running the command it was also running over the vendor folder, maybe a ./node_modules/.bin/prettier --write "src/**/*" would be safer
For using it from any IDE without a plugin (if it detects external files changes automatically) :
npm install prettier onchange @prettier/plugin-php --save-dev
Register a new run command on package.json :
{
...
"scripts": {
...
"watch": "./node_modules/.bin/onchange \"src/**/*.php\" -- ./node_modules/.bin/prettier --write {{changed}}"
}
...
}
And then just run from npm run watch - it will correct automatically any changed file
Note that automatic changes saves (VSCode : File / Automatic Saves) should be disabled in order to avoid conflicts when typing.
So i think for install, maybe we could show both options, following the prettier docs? https://prettier.io/docs/en/install.html (also we need to update to use the npm modules)
npm
npm install --save-dev prettier @prettier/plugin-php
#or globally
npm install --global prettier @prettier/plugin-php
yarn
yarn add --dev prettier @prettier/plugin-php
#or globally
yarn global add prettier @prettier/plugin-php
Is the plugin working with a released (non-master) version of prettier?
And for instructions on how to run, we could show info for both
"If you installed prettier as a local dependency, you can add prettier as a script in your package.json to run
scripts: {
"prettier":"prettier"
}
and then run via npm run prettier path/to/file.php --write or yarn run prettier path/to/file.php. Or if you installed globally, run prettier path/to/file.php --write.
Good question - I'm not sure but we should confirm
Last release was Feb 28, so probably not - @azz @vjeux do you guys think prettier will have another release coming up soon or should we just reference the latest from master?
Updated the PR - shall we move the discussion over to #364?
I haven't been very actively monitoring prettier lately @j-f1 would know more about when the next release is planned.
https://github.com/prettier/prettier/issues/4231 is all I know. Looks like @suchipi is going to do the release.