Skip to content

Commit

Permalink
feat(app-webpack): (backport from v4 beta) create .npmrc in dist/elec…
Browse files Browse the repository at this point in the history
…tron/UnPackaged even if the project doesn't have one #17504
  • Loading branch information
rstoenescu committed Sep 19, 2024
1 parent 99a8ec8 commit 470fc3f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app-webpack/lib/webpack/electron/plugin.npmrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ module.exports = class ElectronPackageJson {
this.cfg = cfg

const npmrc = appPaths.resolve.app('.npmrc')

if (existsSync(npmrc) === false) {
this.source = null
return
}

let content = readFileSync(npmrc, 'utf-8')
let content = existsSync(npmrc)
? readFileSync(npmrc, 'utf-8')
: ''

if (content.indexOf('shamefully-hoist') === -1) {
content += '\n# needed by pnpm\nshamefully-hoist=true'
Expand All @@ -29,10 +25,8 @@ module.exports = class ElectronPackageJson {
}

apply (compiler) {
if (this.source !== null) {
compiler.hooks.thisCompilation.tap('package.json', compilation => {
compilation.emitAsset('.npmrc', new sources.RawSource(this.source))
})
}
compiler.hooks.thisCompilation.tap('npmrc', compilation => {
compilation.emitAsset('.npmrc', new sources.RawSource(this.source))
})
}
}

0 comments on commit 470fc3f

Please sign in to comment.