Skip to content

Commit 20f3c92

Browse files
committed
refactor: silence installation
To address modern pnpm policy (https://pnpm.io/cli/approve-builds) from poc was backported util to check ignored builds
1 parent 799128d commit 20f3c92

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/utils/cli/pnpmIgnored.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { execSync } from 'node:child_process'
2+
3+
export function pnpmIgnored (root: string) {
4+
const pnpmVersion = execSync(`cd ${root} && pnpm -v`, { encoding: 'utf8' }).trim()
5+
const [major] = pnpmVersion.split('.').map(Number)
6+
if (major && major >= 10) {
7+
const detect = execSync(`cd ${root} && pnpm ignored-builds`, { encoding: 'utf8' })
8+
if (detect.startsWith('Automatically ignored builds during installation:\n None')) return
9+
return detect
10+
}
11+
}

src/utils/installDependencies.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { installDependencies as installDependencies$1 } from 'nypm'
2+
import { pnpmIgnored } from './cli/pnpmIgnored'
23

34
const userAgent = process.env.npm_config_user_agent ?? ''
45

@@ -10,9 +11,17 @@ export async function installDependencies (root: string = process.cwd(), manager
1011
await installDependencies$1({
1112
packageManager: manager,
1213
cwd: root,
13-
}).catch(() => {
14-
console.error(
15-
`Failed to install dependencies using ${manager}.`
16-
)
14+
silent: true,
1715
})
16+
.catch(() => {
17+
console.error(
18+
`Failed to install dependencies using ${manager}.`
19+
)
20+
})
21+
.then(() => {
22+
if (manager === 'pnpm') {
23+
const detect = pnpmIgnored(root)
24+
if (detect) console.warn(detect)
25+
}
26+
})
1827
}

0 commit comments

Comments
 (0)