Skip to content

Commit aa14231

Browse files
Lukas Holzerkodiakhq[bot]
Lukas Holzer
andauthored
fix: fixes an issue with yarn pnp on installing (#3841)
* fix: fixes an issue with yarn pnp on installing * chore: sir lintfix complained 🧐 * chore: good o'l 🪟 is different Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 3d9353d commit aa14231

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

scripts/postinstall.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const { createMainCommand } = require('../src/commands')
2-
const { createAutocompletion } = require('../src/lib/completion')
1+
const process = require('process')
32

43
const id = (message) => message
54

@@ -23,9 +22,19 @@ const format = (message, styles) => {
2322
}
2423

2524
const postInstall = () => {
26-
// create or update the autocompletion definition
27-
const program = createMainCommand()
28-
createAutocompletion(program)
25+
// yarn plug and play seems to have an issue with reading an esm file by building up the cache.
26+
// as yarn pnp analyzes everything inside the postinstall
27+
// yarn pnp executes it out of a .yarn folder .yarn/unplugged/netlify-cli-file-fb026a3a6d/node_modules/netlify-cli/scripts/postinstall.js
28+
if (!process.argv[1].includes('.yarn')) {
29+
// eslint-disable-next-line node/global-require
30+
const { createMainCommand } = require('../src/commands')
31+
// eslint-disable-next-line node/global-require
32+
const { createAutocompletion } = require('../src/lib/completion')
33+
34+
// create or update the autocompletion definition
35+
const program = createMainCommand()
36+
createAutocompletion(program)
37+
}
2938

3039
console.log('')
3140
console.log(format('Success! Netlify CLI has been installed!', ['greenBright', 'bold', 'underline']))

0 commit comments

Comments
 (0)