Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(exe): use the strict equality operator, and make JSON.parse execute correctly #4571

Merged
merged 4 commits into from
Apr 14, 2022
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
12 changes: 6 additions & 6 deletions packages/exe/setup.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const path = require('path')
const fs = require('fs')

const platform = process.platform == 'win32'
const platform = process.platform === 'win32'
? 'win'
: process.platform == 'darwin'
: process.platform === 'darwin'
? 'macos'
: process.platform
const arch = platform == 'win' && process.arch == 'ia32' ? 'x86' : process.arch
const arch = platform === 'win' && process.arch === 'ia32' ? 'x86' : process.arch

const pkgName = `@pnpm/${platform}-${arch}`
const pkgJson = require.resolve(`${pkgName}/package.json`)
Expand All @@ -18,8 +18,8 @@ if (subpkg.bin != null) {

linkSync(bin, path.resolve(process.cwd(), executable))

if (platform == 'win') {
const pkg = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'package.json')))
if (platform === 'win') {
const pkg = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf8'))
fs.writeFileSync(path.resolve(process.cwd(), 'pnpm'), 'This file intentionally left blank')
pkg.bin.pnpm = 'pnpm.exe'
fs.writeFileSync(path.resolve(process.cwd(), 'package.json'), JSON.stringify(pkg, null, 2))
Expand All @@ -30,7 +30,7 @@ function linkSync(src, dest) {
try {
fs.unlinkSync(dest)
} catch (e) {
if (e.code != 'ENOENT') {
if (e.code !== 'ENOENT') {
throw e
}
}
Expand Down