Skip to content

Commit

Permalink
DEBUG2
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Jun 24, 2023
1 parent b28343d commit 2899677
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/package-managers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,13 @@ async function viewMany(
const npmConfigProjectPath = options.packageFile ? path.join(options.packageFile, '../.npmrc') : null
const npmConfigProject = options.packageFile ? findNpmConfig(npmConfigProjectPath || undefined) : null
const npmConfigCWDPath = options.cwd ? path.join(options.cwd, '.npmrc') : null
// const npmConfigLocal2 = findNpmConfig()
// const npmConfigLocal2 = findNpmConfig('./')
// const npmConfigLocal2 = findNpmConfig(process.cwd())
console.log('!!!', process.cwd())
const npmConfigLocal2 = findNpmConfig(path.join(process.cwd(), '.npmrc'))
const npmConfigCWD = options.cwd ? findNpmConfig(npmConfigCWDPath!) : null
console.log({ npmConfigWorkspaceProject })

if (npmConfigWorkspaceProject && Object.keys(npmConfigWorkspaceProject).length > 0) {
print(options, `\nnpm config (workspace project):`, 'verbose')
Expand All @@ -373,13 +379,18 @@ async function viewMany(
print(options, omit(npmConfig, 'cache'), 'verbose')
}

if (npmConfigLocal2 && Object.keys(npmConfigLocal2).length > 0) {
print(options, `\nnpm config (local2):`, 'verbose')
print(options, omit(npmConfigLocal2, 'cache'), 'verbose')
}

if (npmConfigLocal && Object.keys(npmConfigLocal).length > 0) {
print(options, `\nnpm config (local override):`, 'verbose')
print(options, omit(npmConfigLocal, 'cache'), 'verbose')
}

if (npmConfigProject && Object.keys(npmConfigProject).length > 0) {
print(options, `\npm config (project: ${npmConfigProjectPath}):`, 'verbose')
print(options, `\nnpm config (project: ${npmConfigProjectPath}):`, 'verbose')
print(options, omit(npmConfigProject, 'cache'), 'verbose')
}

Expand All @@ -393,14 +404,15 @@ async function viewMany(
...npmConfigWorkspaceProject,
...npmConfig,
...npmConfigLocal,
...npmConfigLocal2,
...npmConfigProject,
...npmConfigCWD,
...(options.registry ? { registry: options.registry, silent: true } : null),
...(options.timeout ? { timeout: options.timeout } : null),
fullMetadata: fieldsExtended.includes('time'),
}

const isMerged = npmConfigWorkspaceProject || npmConfigLocal || npmConfigProject || npmConfigCWD
const isMerged = npmConfigWorkspaceProject || npmConfigLocal || npmConfigLocal2 || npmConfigProject || npmConfigCWD
print(options, `\nUsing${isMerged ? ' merged' : ''} npm config:`, 'verbose')
// omit cache since it is added to every config
print(options, omit(npmConfigMerged, 'cache'), 'verbose')
Expand Down
1 change: 1 addition & 0 deletions src/package-managers/pnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type PnpmList = {
/** Reads the npmrc config file from the pnpm-workspace.yaml directory. */
const npmConfigFromPnpmWorkspace = memoize(async (options: Options): Promise<NpmConfig> => {
const pnpmWorkspacePath = await findUp('pnpm-workspace.yaml')
console.log({ pnpmWorkspacePath })
if (!pnpmWorkspacePath) return {}

const pnpmWorkspaceDir = path.dirname(pnpmWorkspacePath)
Expand Down
2 changes: 1 addition & 1 deletion test/workspaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ describe('stubbed', () => {
})

describe('pnpm', () => {
it('read packages from pnpm-workspaces.yaml', async () => {
it('read packages from pnpm-workspace.yaml', async () => {
const tempDir = await setup(['packages/**'], { pnpm: true })
try {
const output = await spawn('node', [bin, '--jsonAll', '--workspaces'], { cwd: tempDir }).then(JSON.parse)
Expand Down

0 comments on commit 2899677

Please sign in to comment.