diff --git a/lib/definitions/plugins.d.ts b/lib/definitions/plugins.d.ts index 06e5e4f7b6..35e38b63ab 100644 --- a/lib/definitions/plugins.d.ts +++ b/lib/definitions/plugins.d.ts @@ -5,13 +5,6 @@ interface IPluginsService { getAllInstalledPlugins(): IFuture; ensureAllDependenciesAreInstalled(): IFuture; afterPrepareAllPlugins(): IFuture; - /** - * Installs all devDependencies of the project. - * In case all of them are already installed, no operation will be executed. - * In case any of them is missing, all of them will be installed. - * @return {IFuture} - */ - installDevDependencies(): IFuture; } interface IPluginData extends INodeModuleData { diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 9ef7395a04..948c169c1c 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -158,8 +158,13 @@ export class PlatformService implements IPlatformService { return (() => { this.validatePlatform(platform); - //Install dev-dependencies here, so before-prepare hooks will be executed correctly. - this.$pluginsService.installDevDependencies().wait(); + //We need dev-dependencies here, so before-prepare hooks will be executed correctly. + try { + this.$pluginsService.ensureAllDependenciesAreInstalled().wait(); + } catch(err) { + this.$logger.trace(err); + this.$errors.failWithoutHelp(`Unable to install dependencies. Make sure your package.json is valid and all dependencies are correct. Error is: ${err.message}`); + } this.preparePlatformCore(platform).wait(); }).future()(); @@ -223,7 +228,6 @@ export class PlatformService implements IPlatformService { // Process node_modules folder let appDir = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME); try { - this.$pluginsService.ensureAllDependenciesAreInstalled().wait(); let tnsModulesDestinationPath = path.join(appDir, PlatformService.TNS_MODULES_FOLDER_NAME); this.$broccoliBuilder.prepareNodeModules(tnsModulesDestinationPath, platform, lastModifiedTime).wait(); } catch(error) { diff --git a/lib/services/plugins-service.ts b/lib/services/plugins-service.ts index 4b497b6b51..0951f4de4e 100644 --- a/lib/services/plugins-service.ts +++ b/lib/services/plugins-service.ts @@ -160,7 +160,8 @@ export class PluginsService implements IPluginsService { return (() => { let installedDependencies = this.$fs.exists(this.nodeModulesPath).wait() ? this.$fs.readDirectory(this.nodeModulesPath).wait() : []; let packageJsonContent = this.$fs.readJson(this.getPackageJsonFilePath()).wait(); - if(this.$options.force || (packageJsonContent.dependencies && _.difference(_.keys(packageJsonContent.dependencies), installedDependencies).length)) { + let allDependencies = _.keys(packageJsonContent.dependencies).concat(_.keys(packageJsonContent.devDependencies)); + if(this.$options.force || _.difference(allDependencies, installedDependencies).length) { let command = "npm install "; if(this.$options.ignoreScripts) { command += "--ignore-scripts"; @@ -185,22 +186,6 @@ export class PluginsService implements IPluginsService { return this.executeForAllInstalledPlatforms(action); } - public installDevDependencies(): IFuture { - return (() => { - let installedDependencies = this.$fs.exists(this.nodeModulesPath).wait() ? this.$fs.readDirectory(this.nodeModulesPath).wait() : []; - let packageJsonContent = this.$fs.readJson(this.getPackageJsonFilePath()).wait(); - let devDependencies = _.keys(packageJsonContent.devDependencies); - if(devDependencies.length && (this.$options.force || _.difference(devDependencies, installedDependencies).length)) { - let command = `npm install ${devDependencies.join(" ")}`; - if(this.$options.ignoreScripts) { - command += "--ignore-scripts"; - } - this.$logger.trace(`Command for installing devDependencies is: '${command}'.`); - this.$childProcess.exec(command, { cwd: this.$projectData.projectDir }).wait(); - } - }).future()(); - } - private get nodeModulesPath(): string { return path.join(this.$projectData.projectDir, "node_modules"); } diff --git a/test/platform-service.ts b/test/platform-service.ts index 2bf7b3c0b7..a4a766ecb5 100644 --- a/test/platform-service.ts +++ b/test/platform-service.ts @@ -49,8 +49,7 @@ function createTestInjector() { }, ensureAllDependenciesAreInstalled: () => { return Future.fromResult(); - }, - installDevDependencies: () => Future.fromResult() + } }); testInjector.register("projectFilesManager", ProjectFilesManagerLib.ProjectFilesManager); testInjector.register("hooksService", stubs.HooksServiceStub);