Skip to content

Commit 2c65aba

Browse files
committed
fixed update platform command
fix error handling on npm.view called with invalid tgz added output to npm.install
1 parent 40566ce commit 2c65aba

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/node-package-manager.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class NodePackageManager implements INodePackageManager {
2525
}
2626

2727
let jsonContentBefore = this.$fs.readJson(path.join(pathToSave, "package.json")).wait();
28-
// let dependenciesBefore: Array<string> = [];
2928
let dependenciesBefore = _.keys(jsonContentBefore.dependencies).concat(_.keys(jsonContentBefore.devDependencies));
3029

3130
let flags = this.getFlagsString(config, true);
@@ -36,6 +35,8 @@ export class NodePackageManager implements INodePackageManager {
3635
params = params.concat(flags);
3736
try {
3837
this.$childProcess.spawnFromEvent(this.getNpmExecutableName(), params, "close", { cwd: pathToSave }).wait();
38+
let spawnResult:ISpawnResult = this.$childProcess.spawnFromEvent(this.getNpmExecutableName(), params, "close", { cwd: pathToSave }).wait();
39+
this.$logger.out(spawnResult.stdout);
3940
} catch (err) {
4041
if (err.message && err.message.indexOf("EPEERINVALID") !== -1) {
4142
// Not installed peer dependencies are treated by npm 2 as errors, but npm 3 treats them as warnings.
@@ -92,7 +93,12 @@ export class NodePackageManager implements INodePackageManager {
9293
public view(packageName: string, config: any): IFuture<any> {
9394
return (() => {
9495
let flags = this.getFlagsString(config, false);
95-
let viewResult = this.$childProcess.exec(`npm view ${packageName} ${flags}`).wait();
96+
let viewResult: any;
97+
try {
98+
viewResult = this.$childProcess.exec(`npm view ${packageName} ${flags}`).wait();
99+
} catch(e) {
100+
this.$errors.failWithoutHelp(e);
101+
}
96102
return JSON.parse(viewResult);
97103
}).future<any>()();
98104
}

lib/services/platform-service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,11 @@ export class PlatformService implements IPlatformService {
692692

693693
let newVersion = version === constants.PackageVersion.NEXT ?
694694
this.$npmInstallationManager.getNextVersion(platformData.frameworkPackageName).wait() :
695-
this.$npmInstallationManager.getLatestVersion(platformData.frameworkPackageName).wait();
696-
let installedModuleDir = this.$npmInstallationManager.install(platformData.frameworkPackageName, this.$projectData.projectDir, {version: newVersion}).wait();
695+
version || this.$npmInstallationManager.getLatestCompatibleVersion(platformData.frameworkPackageName).wait();
696+
let installedModuleDir = this.$npmInstallationManager.install(platformData.frameworkPackageName, this.$projectData.projectDir, {version: newVersion, dependencyType: "save"}).wait();
697697
let cachedPackageData = this.$fs.readJson(path.join(installedModuleDir, "package.json")).wait();
698698
newVersion = (cachedPackageData && cachedPackageData.version) || newVersion;
699+
this.$npm.uninstall(platformData.frameworkPackageName, {save: true}, this.$projectData.projectDir).wait();
699700

700701
let canUpdate = platformData.platformProjectService.canUpdatePlatform(installedModuleDir).wait();
701702
if (canUpdate) {
@@ -723,6 +724,7 @@ export class PlatformService implements IPlatformService {
723724
this.removePlatforms([packageName]).wait();
724725
packageName = newVersion ? `${packageName}@${newVersion}` : packageName;
725726
this.addPlatform(packageName).wait();
727+
this.$logger.out("Successfully updated to version ", newVersion);
726728
}).future<void>()();
727729
}
728730

0 commit comments

Comments
 (0)