@contember/cli-common
Advanced tools
Comparing version 1.3.0-beta.3 to 1.3.0-beta.4
@@ -29,5 +29,5 @@ import { PackageManager } from './packageManagers/PackageManager'; | ||
constructor(fsManager: FsManager, packageManagers: PackageManager[]); | ||
resolve(dir: string): Promise<PackageWorkspace>; | ||
resolve(dir: string, packageJsonFound?: boolean): Promise<PackageWorkspace>; | ||
private resolvePackageManager; | ||
} | ||
//# sourceMappingURL=PackageWorkspace.d.ts.map |
@@ -90,8 +90,22 @@ "use strict"; | ||
} | ||
async resolve(dir) { | ||
async resolve(dir, packageJsonFound = false) { | ||
const packageJson = await this.fsManager.tryReadJson((0, node_path_1.join)(dir, 'package.json')); | ||
if (!packageJson) { | ||
throw `package.json not found.`; | ||
if (dir === '/') { | ||
if (packageJsonFound) { | ||
throw `No lockfile found. Please install dependencies using package manager of your choice.`; | ||
} | ||
else { | ||
throw `package.json not found.`; | ||
} | ||
} | ||
return await this.resolve((0, node_path_1.dirname)(dir), packageJsonFound); | ||
} | ||
const pm = await this.resolvePackageManager({ dir, packageJson }); | ||
if (!pm) { | ||
if (dir === '/') { | ||
throw `No lockfile found. Please install dependencies using package manager of your choice.`; | ||
} | ||
return await this.resolve((0, node_path_1.dirname)(dir), true); | ||
} | ||
const rootPackage = new Package_1.Package(dir, true, packageJson); | ||
@@ -107,3 +121,3 @@ const workspacePackages = await pm.readWorkspacePackages({ dir, packageJson }); | ||
} | ||
throw `No lockfile found. Please install dependencies using package manager of your choice.`; | ||
return null; | ||
} | ||
@@ -110,0 +124,0 @@ } |
{ | ||
"name": "@contember/cli-common", | ||
"version": "1.3.0-beta.3", | ||
"version": "1.3.0-beta.4", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -106,8 +106,23 @@ import { PackageManager } from './packageManagers/PackageManager' | ||
public async resolve(dir: string): Promise<PackageWorkspace> { | ||
public async resolve(dir: string, packageJsonFound: boolean = false): Promise<PackageWorkspace> { | ||
const packageJson = await this.fsManager.tryReadJson<PackageJson>(join(dir, 'package.json')) | ||
if (!packageJson) { | ||
throw `package.json not found.` | ||
if (dir === '/') { | ||
if (packageJsonFound) { | ||
throw `No lockfile found. Please install dependencies using package manager of your choice.` | ||
} else { | ||
throw `package.json not found.` | ||
} | ||
} | ||
return await this.resolve(dirname(dir), packageJsonFound) | ||
} | ||
const pm = await this.resolvePackageManager({ dir, packageJson }) | ||
if (!pm) { | ||
if (dir === '/') { | ||
throw `No lockfile found. Please install dependencies using package manager of your choice.` | ||
} | ||
return await this.resolve(dirname(dir), true) | ||
} | ||
const rootPackage = new Package(dir, true, packageJson) | ||
@@ -119,3 +134,3 @@ const workspacePackages = await pm.readWorkspacePackages({ dir, packageJson }) | ||
private async resolvePackageManager(args: { dir: string; packageJson: PackageJson }): Promise<PackageManager> { | ||
private async resolvePackageManager(args: { dir: string; packageJson: PackageJson }): Promise<PackageManager | null> { | ||
for (const pm of this.packageManagers) { | ||
@@ -126,4 +141,4 @@ if (await pm.isActive(args)) { | ||
} | ||
throw `No lockfile found. Please install dependencies using package manager of your choice.` | ||
return null | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
228961
3296