Skip to content

Commit

Permalink
feat: detect install command
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode authored and jsmrcaga committed Mar 26, 2021
1 parent 2c0108a commit a733230
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -38,7 +38,7 @@ The inputs this action uses are:
| `NETLIFY_DEPLOY_MESSAGE` | `false` | '' | An optional deploy message |
| `build_directory` | `false` | `'build'` | The directory where your files are built |
| `functions_directory` | `false` | N/A | The (optional) directory where your Netlify functions are stored |
| `install_command` | `false` | `npm i` | The (optional) command to install dependencies |
| `install_command` | `false` | Auto-detected | The (optional) command to install dependencies. Runs `yarn` when `yarn.lock` is found; `npm i` otherwise |
| `build_command` | `false` | `npm run build` | The (optional) command to build static website |
| `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) |

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -36,7 +36,7 @@ inputs:
install_command:
description: 'Command to install dependencies'
required: false
default: 'npm i'
default: ''

build_command:
description: 'Command to build static website'
Expand Down
10 changes: 9 additions & 1 deletion entrypoint.sh
Expand Up @@ -12,7 +12,15 @@ BUILD_COMMAND=$7
DEPLOY_ALIAS=$8

# Install dependencies
eval ${INSTALL_COMMAND:-"npm i"}
if [[ -n $INSTALL_COMMAND ]]
then
eval $INSTALL_COMMAND
elif [[ -f yarn.lock ]]
then
yarn
else
npm i
fi

# Build project
eval ${BUILD_COMMAND:-"npm run build"}
Expand Down

0 comments on commit a733230

Please sign in to comment.