Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow pnpm to be used as package manager #71

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ typings/

# Optional eslint cache
.eslintcache

.vscode
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ configuration options:
Provided as an [input][github-action-input].
Defaults to `{actor}@users.noreply.github.com`, where `{actor}` is the GitHub username
of the action actor.

- **pkg-manager**: Provide a custom package manager other than npm.
Provided as an [input][github-action-input].

### Org or User Pages

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ inputs:
description: "The email adress under which the deploy commit is pushed to the deploy branch."
required: false
default: ""
pkg-manager:
description: "The package manager used to manage the project"
required: false
default: ""
runs:
using: "node12"
main: "./dist/index.js"
12 changes: 10 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import * as ioUtil from '@actions/io/lib/io-util'

const DEFAULT_DEPLOY_BRANCH = 'master'

async function getPkgManager(workingDir: string) {
if (await ioUtil.exists(`${workingDir}/pnpm-lock.yaml`)) return 'pnpm'
if (await ioUtil.exists(`${workingDir}/yarn.lock`)) return 'yarn'
return 'npm'
}

async function run(): Promise<void> {
try {
const skipPublish = (core.getInput('skip-publish') || 'false').toUpperCase()
Expand All @@ -31,7 +37,7 @@ async function run(): Promise<void> {
}

const workingDir = core.getInput('working-dir') || '.'
const pkgManager = (await ioUtil.exists(`${workingDir}/yarn.lock`)) ? 'yarn' : 'npm'
const pkgManager = core.getInput('pkg-manager') || (await getPkgManager(workingDir))
console.log(`Installing your site's dependencies using ${pkgManager}.`)
await exec.exec(`${pkgManager} install`, [], {cwd: workingDir})
console.log('Finished installing dependencies.')
Expand All @@ -49,7 +55,9 @@ async function run(): Promise<void> {
const cnameExists = await ioUtil.exists(`${workingDir}/CNAME`)
if (cnameExists) {
console.log('Copying CNAME over.')
await io.cp(`${workingDir}/CNAME`, `${workingDir}/public/CNAME`, {force: true})
await io.cp(`${workingDir}/CNAME`, `${workingDir}/public/CNAME`, {
force: true,
})
console.log('Finished copying CNAME.')
}

Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-gh-pages-action",
"version": "2.1.1",
"version": "2.2.1",
"description": "GitHub Action to build and deploy your Gatsby site to GitHub Pages ❤️🎩",
"main": "dist/index.js",
"scripts": {
Expand Down