Skip to content

Commit

Permalink
fix: 🐛 action not working in windows or with pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
stormslowly committed Jun 20, 2022
1 parent be2de7b commit d322bd2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ inputs:
install-command:
description: 'Custom install command to use'
required: false
hash-file:
description: 'Path to the file for cypress cache key generation'
required: false
runTests:
description: 'Whether or not to run tests'
required: false
Expand Down
21 changes: 17 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const cliParser = require('argument-vector')()
const findYarnWorkspaceRoot = require('find-yarn-workspace-root')
const debug = require('debug')('@cypress/github-action')
const { ping } = require('./src/ping')
const {getInput} = require("./dist");

/**
* Parses input command, finds the tool and
Expand Down Expand Up @@ -102,10 +103,18 @@ const packageLockFilename = path.join(

const useYarn = () => fs.existsSync(yarnFilename)

const gegUserSpecifiedHashFile = () => {
const userSpecifiedHashFile = core.getInput('lock-hash');
if (userSpecifiedHashFile) {
return path.join(workingDirectory, userSpecifiedHashFile);
}
return useYarn() ? yarnFilename : packageLockFilename;
}

const lockHash = () => {
const lockFilename = useYarn() ? yarnFilename : packageLockFilename
const fileHash = hasha.fromFileSync(lockFilename)
debug(`Hash from file ${lockFilename} is ${fileHash}`)
const hashFile = gegUserSpecifiedHashFile();
const fileHash = hasha.fromFileSync(hashFile);
debug(`Hash from file ${hashFile} is ${fileHash}`)
return fileHash
}

Expand Down Expand Up @@ -635,7 +644,11 @@ const runTests = async () => {
}

// export common environment variables that help run Cypress
core.exportVariable('CYPRESS_CACHE_FOLDER', CYPRESS_CACHE_FOLDER)
if(getInputBool('install', true)) {
// only when cypress is installed by action self, we can export the Cache Folder,
// otherwise use the default one in Cypress
core.exportVariable('CYPRESS_CACHE_FOLDER', CYPRESS_CACHE_FOLDER)
}
core.exportVariable('TERM', 'xterm')

if (customCommand) {
Expand Down

0 comments on commit d322bd2

Please sign in to comment.