Skip to content

Commit

Permalink
feat: is using custom npm command not using yarn paths
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Feb 14, 2024
1 parent 3da6b44 commit cfc4184
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,28 @@ const installInOneFolder = ({
core.debug(`lock filename ${lockInfo.lockFilename}`)
core.debug(`file hash ${lockHash}`)

// if the user provided a custom command like "npm ...", then we cannot
// use Yarn cache paths
let useYarn = lockInfo.useYarn
if (useYarn && installCommand && installCommand.startsWith('npm')) {
core.debug('using NPM command, not using Yarn cache paths')
useYarn = false
}

// enforce the same NPM cache folder across different operating systems
const homeDirectory = os.homedir()
const NPM_CACHE_FOLDER = path.join(homeDirectory, '.npm')

const NPM_CACHE = getCacheParams({
useYarn: lockInfo.useYarn,
useYarn,
homeDirectory,
useRollingCache,
npmCacheFolder: NPM_CACHE_FOLDER,
lockHash
})

const opts = {
useYarn: lockInfo.useYarn,
useYarn,
usePackageLock,
workingDirectory,
npmCacheFolder: NPM_CACHE_FOLDER,
Expand Down
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,28 @@ const installInOneFolder = ({
core.debug(`lock filename ${lockInfo.lockFilename}`)
core.debug(`file hash ${lockHash}`)

// if the user provided a custom command like "npm ...", then we cannot
// use Yarn cache paths
let useYarn = lockInfo.useYarn
if (useYarn && installCommand && installCommand.startsWith('npm')) {
core.debug('using NPM command, not using Yarn cache paths')
useYarn = false
}

// enforce the same NPM cache folder across different operating systems
const homeDirectory = os.homedir()
const NPM_CACHE_FOLDER = path.join(homeDirectory, '.npm')

const NPM_CACHE = getCacheParams({
useYarn: lockInfo.useYarn,
useYarn,
homeDirectory,
useRollingCache,
npmCacheFolder: NPM_CACHE_FOLDER,
lockHash
})

const opts = {
useYarn: lockInfo.useYarn,
useYarn,
usePackageLock,
workingDirectory,
npmCacheFolder: NPM_CACHE_FOLDER,
Expand Down

0 comments on commit cfc4184

Please sign in to comment.