Skip to content

Commit a733230

Browse files
tpluscodejsmrcaga
authored andcommitted
feat: detect install command
1 parent 2c0108a commit a733230

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The inputs this action uses are:
3838
| `NETLIFY_DEPLOY_MESSAGE` | `false` | '' | An optional deploy message |
3939
| `build_directory` | `false` | `'build'` | The directory where your files are built |
4040
| `functions_directory` | `false` | N/A | The (optional) directory where your Netlify functions are stored |
41-
| `install_command` | `false` | `npm i` | The (optional) command to install dependencies |
41+
| `install_command` | `false` | Auto-detected | The (optional) command to install dependencies. Runs `yarn` when `yarn.lock` is found; `npm i` otherwise |
4242
| `build_command` | `false` | `npm run build` | The (optional) command to build static website |
4343
| `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) |
4444

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ inputs:
3636
install_command:
3737
description: 'Command to install dependencies'
3838
required: false
39-
default: 'npm i'
39+
default: ''
4040

4141
build_command:
4242
description: 'Command to build static website'

entrypoint.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ BUILD_COMMAND=$7
1212
DEPLOY_ALIAS=$8
1313

1414
# Install dependencies
15-
eval ${INSTALL_COMMAND:-"npm i"}
15+
if [[ -n $INSTALL_COMMAND ]]
16+
then
17+
eval $INSTALL_COMMAND
18+
elif [[ -f yarn.lock ]]
19+
then
20+
yarn
21+
else
22+
npm i
23+
fi
1624

1725
# Build project
1826
eval ${BUILD_COMMAND:-"npm run build"}

0 commit comments

Comments
 (0)