Skip to content

Commit ed61780

Browse files
committed
Merge pull request #820 from NativeScript/totev/guard-npm-assert
Guard against errors in npm
2 parents d7f8f42 + 3a76740 commit ed61780

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/node-package-manager.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import * as npm from "npm";
66

77
export class NodePackageManager implements INodePackageManager {
88
constructor(private $childProcess: IChildProcess,
9-
private $logger: ILogger,
10-
private $errors: IErrors,
11-
private $fs: IFileSystem,
12-
private $lockfile: ILockFile,
139
private $options: IOptions) { }
1410

1511
public getCache(): string {
@@ -18,7 +14,7 @@ export class NodePackageManager implements INodePackageManager {
1814

1915
public load(config?: any): IFuture<void> {
2016
let future = new Future<void>();
21-
npm.load(config, (err) => {
17+
npm.load(config, (err: Error) => {
2218
if(err) {
2319
future.throw(err);
2420
} else {

lib/services/platform-service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export class PlatformService implements IPlatformService {
7575
npmOptions["version"] = version;
7676
}
7777

78-
let downloadedPackagePath = this.$npmInstallationManager.install(packageToInstall, npmOptions).wait();
79-
let frameworkDir = path.join(downloadedPackagePath, constants.PROJECT_FRAMEWORK_FOLDER_NAME);
80-
frameworkDir = path.resolve(frameworkDir);
81-
8278
try {
79+
let downloadedPackagePath = this.$npmInstallationManager.install(packageToInstall, npmOptions).wait();
80+
let frameworkDir = path.join(downloadedPackagePath, constants.PROJECT_FRAMEWORK_FOLDER_NAME);
81+
frameworkDir = path.resolve(frameworkDir);
82+
8383
this.addPlatformCore(platformData, frameworkDir).wait();
8484
} catch(err) {
8585
this.$fs.deleteDirectory(platformPath).wait();

0 commit comments

Comments
 (0)