From 5b23897061e44fb06ba3c4d8453114447ee2107c Mon Sep 17 00:00:00 2001 From: JeroenVinke Date: Sun, 3 Sep 2017 11:38:45 +0200 Subject: [PATCH] fix(importer): throw clear unsupported error for webpack projects closes https://github.com/aurelia/cli/issues/735 --- lib/commands/import/command.js | 10 ++++++++-- lib/commands/install/command.js | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/commands/import/command.js b/lib/commands/import/command.js index 1f5e56b7e..5dd322f6a 100644 --- a/lib/commands/import/command.js +++ b/lib/commands/import/command.js @@ -2,17 +2,23 @@ const ImportEngine = require('../../importer/import-engine'); const ArgumentParser = require('../install/package-argument-parser'); +const Project = require('../../project').Project; module.exports = class { - static inject() { return [ImportEngine, ArgumentParser]; } + static inject() { return [ImportEngine, ArgumentParser, Project]; } - constructor(engine, argumentParser) { + constructor(engine, argumentParser, project) { this.engine = engine; this.argumentParser = argumentParser; + this.project = project; } execute(args) { + if (this.project.model.bundler && this.project.model.bundler.id !== 'cli') { + throw new Error('This command is only available for the Aurelia CLI Bundler'); + } + let packages = this.argumentParser.parse(args); if (packages.length === 0) { diff --git a/lib/commands/install/command.js b/lib/commands/install/command.js index f85b910af..78e9bffd8 100644 --- a/lib/commands/install/command.js +++ b/lib/commands/install/command.js @@ -3,19 +3,25 @@ const ImportCommand = require('../import/command'); const PackageInstaller = require('../../importer/package-installer'); const ArgumentParser = require('./package-argument-parser'); +const Project = require('../../project').Project; const logger = require('aurelia-logging').getLogger('Install'); module.exports = class { - static inject() { return [PackageInstaller, ImportCommand, ArgumentParser]; } + static inject() { return [PackageInstaller, ImportCommand, ArgumentParser, Project]; } - constructor(packageInstaller, importCommand, argumentParser) { + constructor(packageInstaller, importCommand, argumentParser, project) { this.packageInstaller = packageInstaller; this.importCommand = importCommand; this.argumentParser = argumentParser; + this.project = project; } execute(args) { + if (this.project.model.bundler && this.project.model.bundler.id !== 'cli') { + throw new Error('This command is only available for the Aurelia CLI Bundler'); + } + let packages = new ArgumentParser().parse(args); if (packages.length === 0) {