Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions sources/folderUtils.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
import {UsageError} from 'clipanion';
import {existsSync, mkdirSync, renameSync} from 'fs';
import {homedir, tmpdir} from 'os';
import {join} from 'path';
import process from 'process';
import {UsageError} from 'clipanion';
import {mkdirSync} from 'fs';
import {homedir, tmpdir} from 'os';
import {join} from 'path';
import process from 'process';

import type {NodeError} from './nodeUtils';
import type {NodeError} from './nodeUtils';

export function getInstallFolder() {
if (process.env.COREPACK_HOME == null) {
// TODO: remove this block on the next major.
const oldCorepackDefaultHome = join(homedir(), `.node`, `corepack`);
const newCorepackDefaultHome = join(
process.env.XDG_CACHE_HOME ??
process.env.LOCALAPPDATA ??
join(
homedir(),
process.platform === `win32` ? `AppData/Local` : `.cache`,
),
`node/corepack`,
);
if (
existsSync(oldCorepackDefaultHome) &&
!existsSync(newCorepackDefaultHome)
) {
mkdirSync(newCorepackDefaultHome, {recursive: true});
renameSync(oldCorepackDefaultHome, newCorepackDefaultHome);
}
return newCorepackDefaultHome;
}
return (
process.env.COREPACK_HOME ??
join(
Expand Down