diff --git a/.gitignore b/.gitignore index 496b06e..2333b8d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ typings/ # Optional eslint cache .eslintcache + +.vscode \ No newline at end of file diff --git a/README.md b/README.md index ffca824..032701e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 74fe0a0..fac22f6 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/index.ts b/index.ts index 1e4574c..b8d84fa 100644 --- a/index.ts +++ b/index.ts @@ -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 { try { const skipPublish = (core.getInput('skip-publish') || 'false').toUpperCase() @@ -31,7 +37,7 @@ async function run(): Promise { } 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.') @@ -49,7 +55,9 @@ async function run(): Promise { 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.') } diff --git a/package-lock.json b/package-lock.json index 260b5e0..491e0e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "gatsby-gh-pages-action", "version": "2.1.1", "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 24c89bf..bb6584a 100644 --- a/package.json +++ b/package.json @@ -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": {