Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getModulesPath(projectRoot: string): string {
const workspaceRoot = findWorkspaceRoot(path.resolve(projectRoot)); // Absolute path or null
if (workspaceRoot) {
return path.resolve(workspaceRoot, 'node_modules');
}
return path.resolve(projectRoot, 'node_modules');
}
export function getModulesPath(projectRoot: string): string {
const workspaceRoot = findWorkspaceRoot(path.resolve(projectRoot)); // Absolute path or null
if (workspaceRoot) {
return path.resolve(workspaceRoot, 'node_modules');
}
return path.resolve(projectRoot, 'node_modules');
}
const yarnLockExists = fs.existsSync(join(appRootPath, "yarn.lock"))
if ((packageLockExists || shrinkWrapExists) && yarnLockExists) {
if (overridePackageManager) {
return overridePackageManager
} else {
printSelectingDefaultMessage()
return shrinkWrapExists ? "npm-shrinkwrap" : "npm"
}
} else if (packageLockExists || shrinkWrapExists) {
if (overridePackageManager === "yarn") {
printNoYarnLockfileError()
process.exit(1)
} else {
return shrinkWrapExists ? "npm-shrinkwrap" : "npm"
}
} else if (yarnLockExists || findWorkspaceRoot()) {
return "yarn"
} else {
printNoLockfilesError()
process.exit(1)
}
throw Error()
}
export function getPackageResolution({
packageDetails,
packageManager,
appPath,
}: {
packageDetails: PackageDetails
packageManager: PackageManager
appPath: string
}) {
if (packageManager === "yarn") {
let lockFilePath = "yarn.lock"
if (!existsSync(lockFilePath)) {
const workspaceRoot = findWorkspaceRoot()
if (!workspaceRoot) {
throw new Error("Can't find yarn.lock file")
}
lockFilePath = join(workspaceRoot, "yarn.lock")
}
if (!existsSync(lockFilePath)) {
throw new Error("Can't find yarn.lock file")
}
const appLockFile = parseYarnLockFile(readFileSync(lockFilePath).toString())
if (appLockFile.type !== "success") {
throw new Error("Can't parse lock file")
}
const installedVersion = require(join(
resolve(appPath, packageDetails.path),
"package.json",
export function isUsingYarn(projectRoot: string): boolean {
const workspaceRoot = findWorkspaceRoot(projectRoot);
if (workspaceRoot) {
return fs.existsSync(path.join(workspaceRoot, 'yarn.lock'));
} else {
return fs.existsSync(path.join(projectRoot, 'yarn.lock'));
}
}
export function isUsingYarn(projectRoot: string): boolean {
const workspaceRoot = findWorkspaceRoot(projectRoot);
if (workspaceRoot) {
return fs.existsSync(path.join(workspaceRoot, 'yarn.lock'));
} else {
return fs.existsSync(path.join(projectRoot, 'yarn.lock'));
}
}