This repository was archived by the owner on Jan 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +55
-1
lines changed Expand file tree Collapse file tree 5 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -16,5 +16,6 @@ Prettier is an opinionated code formatter.
1616| Options Id | Description | Type | Default Value |
1717| -----| -----| -----| -----|
1818| version | Select the version to install. | string | latest |
19+ | plugins | Comma-separated list of prettier plugins to install. | string | |
1920
2021
Original file line number Diff line number Diff line change 11{
22 "id" : " prettier" ,
3- "version" : " 1.0 .0" ,
3+ "version" : " 1.1 .0" ,
44 "name" : " Prettier (via npm)" ,
55 "documentationURL" : " http://github.com/devcontainers-contrib/features/tree/main/src/prettier" ,
66 "description" : " Prettier is an opinionated code formatter." ,
1212 " latest"
1313 ],
1414 "type" : " string"
15+ },
16+ "plugins" : {
17+ "default" : " " ,
18+ "description" : " Comma-separated list of prettier plugins to install." ,
19+ "type" : " string"
1520 }
1621 },
1722 "installsAfter" : [
Original file line number Diff line number Diff line change @@ -19,6 +19,36 @@ $nanolayer_location \
1919 --option package=' prettier' --option version=" $VERSION "
2020
2121
22+ PRETTIER_PLUGINS=${PLUGINS:- " " }
23+
24+ setup_npm () {
25+ export NVM_DIR=/usr/local/share/nvm
26+ [ -s " $NVM_DIR /nvm.sh" ] && . " $NVM_DIR /nvm.sh"
27+ }
28+
29+ install_prettier_plugin () {
30+ echo " Installing prettier plugin - $1 "
31+ if ! npm list $1 > /dev/null; then
32+ npm install --save-dev prettier $1
33+ fi
34+ }
35+
36+ # Prettier plugins are expected to be installed locally, not globally
37+ # In particular, VSCode + extensions tend to have issues with this
38+ if [ -n " ${PRETTIER_PLUGINS} " ]; then
39+ if ! type npm > /dev/null 2>&1 ; then
40+ setup_npm
41+ fi
42+
43+ OIFS=$IFS
44+ IFS=' ,'
45+ for plugin in $PRETTIER_PLUGINS ; do
46+ install_prettier_plugin $plugin
47+ done
48+ IFS=$OIFS
49+ fi
50+
51+
2252
2353echo ' Done!'
2454
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ source dev-container-features-test-lib
6+
7+ check " npm list --parseable --depth 0 | grep prettier-plugin-ini" npm list --parseable --depth 0 | grep " prettier-plugin-ini"
8+
9+ reportResults
Original file line number Diff line number Diff line change 44 "features" : {
55 "prettier" : {}
66 }
7+ },
8+ "plugin" : {
9+ "image" : " mcr.microsoft.com/devcontainers/base:debian" ,
10+ "features" : {
11+ "prettier" : {
12+ "version" : " latest" ,
13+ "plugins" : " prettier-plugin-ini"
14+ }
15+ }
716 }
817}
You can’t perform that action at this time.
0 commit comments