Skip to content

Commit

Permalink
fix: πŸ› fixed linting errors related to pnpapi
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jan 11, 2021
1 parent 392a5ae commit 0d32d08
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/pnp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync, readFileSync } from "fs"
import * as pnpapi from "pnpapi"
// eslint-disable-next-line import/no-unresolved
import type * as pnpapi from "pnpapi"
import memoize from "micro-memoize"
import path, { resolve } from "path"
import v8 from "v8"
Expand Down Expand Up @@ -29,9 +30,9 @@ const getInstallState = memoize((workspaceRoot: string) => {
const serializedState = readFileSync(
resolve(workspaceRoot, ".yarn", "install-state.gz")
)
const installState: InstallState = v8.deserialize(
const installState = v8.deserialize(
zlib.gunzipSync(serializedState)
)
) as InstallState
return installState
})

Expand All @@ -46,7 +47,7 @@ export function getBinaries(workspaceRoot: string, packageName: string) {
getDependencyTreeRoots,
} = getPnpApi(workspaceRoot)

let packageLocator = getDependencyTreeRoots().find(
const packageLocator = getDependencyTreeRoots().find(
(x) => x.name === packageName
)

Expand Down Expand Up @@ -94,8 +95,8 @@ export function getBinaries(workspaceRoot: string, packageName: string) {
return binaries
}

const getPnpApi = memoize(function getPnpApi(workspaceRoot: string): PnpAPI {
const getPnpApi = memoize(function getPnpApi(workspaceRoot: string) {
const jsPath = path.resolve(workspaceRoot, ".pnp.js")
const cjsPath = path.resolve(workspaceRoot, ".pnp.cjs")
return existsSync(jsPath) ? require(jsPath) : require(cjsPath)
return (existsSync(jsPath) ? require(jsPath) : require(cjsPath)) as PnpAPI
})

0 comments on commit 0d32d08

Please sign in to comment.