diff --git a/dist/index.js b/dist/index.js index 85db4e7f1..a916c4d01 100644 --- a/dist/index.js +++ b/dist/index.js @@ -74454,20 +74454,31 @@ const packageLockFilename = path.join( ) const useYarn = () => fs.existsSync(yarnFilename) - const usePnpm = () => fs.existsSync(pnpmLockFilename) +const useNpm = () => fs.existsSync(packageLockFilename) const lockHash = () => { const lockFilename = useYarn() ? yarnFilename : usePnpm() ? pnpmLockFilename - : packageLockFilename + : useNpm() + ? packageLockFilename + : noLockFile() const fileHash = hasha.fromFileSync(lockFilename) debug(`Hash from file ${lockFilename} is ${fileHash}`) return fileHash } +const noLockFile = () => { + core.error( + `Action failed. Missing package manager lockfile. ` + + `Expecting one of package-lock.json (npm), pnpm-lock.yaml (pnpm) or yarn.lock (yarn) in working-directory ` + + workingDirectory + ) + process.exit(1) +} + // enforce the same NPM cache folder across different operating systems const NPM_CACHE_FOLDER = path.join(homeDirectory, '.npm') const getNpmCache = () => { diff --git a/index.js b/index.js index 72b07f359..459ebf011 100644 --- a/index.js +++ b/index.js @@ -103,20 +103,31 @@ const packageLockFilename = path.join( ) const useYarn = () => fs.existsSync(yarnFilename) - const usePnpm = () => fs.existsSync(pnpmLockFilename) +const useNpm = () => fs.existsSync(packageLockFilename) const lockHash = () => { const lockFilename = useYarn() ? yarnFilename : usePnpm() ? pnpmLockFilename - : packageLockFilename + : useNpm() + ? packageLockFilename + : noLockFile() const fileHash = hasha.fromFileSync(lockFilename) debug(`Hash from file ${lockFilename} is ${fileHash}`) return fileHash } +const noLockFile = () => { + core.error( + `Action failed. Missing package manager lockfile. ` + + `Expecting one of package-lock.json (npm), pnpm-lock.yaml (pnpm) or yarn.lock (yarn) in working-directory ` + + workingDirectory + ) + process.exit(1) +} + // enforce the same NPM cache folder across different operating systems const NPM_CACHE_FOLDER = path.join(homeDirectory, '.npm') const getNpmCache = () => {