当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript commands.list方法代码示例

本文整理汇总了TypeScript中bower.commands.list方法的典型用法代码示例。如果您正苦于以下问题:TypeScript commands.list方法的具体用法?TypeScript commands.list怎么用?TypeScript commands.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bower.commands的用法示例。


在下文中一共展示了commands.list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: resolve

 (resolve, _reject) =>
     bower.commands.list({}, {offline: true})
         .on('end',
             (result: any) => {
               if (result && result.dependencies &&
                   result.dependencies.polymer &&
                   result.dependencies.polymer.pkgMeta &&
                   result.dependencies.polymer.pkgMeta.version) {
                 resolve(result.dependencies.polymer.pkgMeta.version);
               } else {
                 resolve('');
               }
             })
         .on('error', (oops: Error) => {
           resolve('');
           console.warn(oops.message);
         }));
开发者ID:asdfg9822,项目名称:polymer-cli,代码行数:17,代码来源:build.ts

示例2: list

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export default function list(adapter: CodeAdapter, progressIndicator:ProgressIndicator) {
	var bower = require('bower');

	bower.commands
		.list({ xrelative: true, xpaths: true }, { offline: false })
		.on('error', function(error) {
			adapter.logError(error);
			vscode.window.showErrorMessage('bower install failed! View Output window for further details');
		}).on('log', function(msg) {
			adapter.log(msg);
		}).on('end', function(installed) {
			adapter.log(installed);
			adapter.log(installed.dependencies);
		})
		.on('prompt', function(prompts, callback) {
			adapter.prompt(prompts, callback);
		});
}
开发者ID:Tyriar,项目名称:bowerVSCode,代码行数:20,代码来源:list.ts

示例3: update

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export default function update(adapter: CodeAdapter, progressIndicator: ProgressIndicator) {
	progressIndicator.beginTask("bower list");
	var bower = require('bower');

	bower.commands
		.list({ paths: true }, { offline: true })
		.on('error', function(error) {
			progressIndicator.endTask("bower list");
			adapter.logError(error);
			vscode.window.showErrorMessage('bower uninstall failed! View Output window for further details');
		}).on('log', function(msg) {
			adapter.log(msg);
		}).on('end', function(installed) {
			progressIndicator.endTask("bower list");
			var installedPackages = Object.keys(installed);
			var packages = installedPackages.map(item=> { return { label: item, description: (Array.isArray(installed[item]) ? installed[item][0] : installed[item]), name: item, all: false } });
			packages = [{ label: "All", description: "", name: "", all: true }].concat(packages);
			displayPackageList(packages);
		}).on('prompt', function(prompts, callback) {
			adapter.prompt(prompts, callback);
		});


	function displayPackageList(packages: vscode.QuickPickItem[]) {
		vscode.window.showQuickPick(packages, { placeHolder: "Select a package to update, or Select 'All'" }).then(function(item) {
			if (item) updatePackages(item);
		});
	}
	function updatePackages(pkg: any) {
		var pkgNames = null;
		var updateALL = true;
		if (pkg.all !== true) {
			pkgNames = [pkg.name];
			updateALL = false;
		}

		progressIndicator.beginTask("bower update");

		bower.commands
			.update(pkgNames)
			.on('error', function(error) {
				progressIndicator.endTask("bower update");
				adapter.logError(error);
				vscode.window.showErrorMessage('bower update failed! View Output window for further details');
			}).on('log', function(msg) {
				adapter.log(msg);
			}).on('end', function() {
				progressIndicator.endTask("bower update");
				var msg = "";
				if (updateALL) {
					msg = "bower packages updated successfully";
				}
				else {
					msg = "bower package '" + pkgNames[0] + "' updated successfully";
				}
				vscode.window.showInformationMessage(msg);
			}).on('prompt', function(prompts, callback) {
				adapter.prompt(prompts, callback);
			});
	}
}
开发者ID:Tyriar,项目名称:bowerVSCode,代码行数:63,代码来源:update.ts

示例4: uninstall

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export default function uninstall(adapter: CodeAdapter, progressIndicator:ProgressIndicator) {
	var bower = require('bower');

	bower.commands
		.list({paths:true}, { offline: true })
		.on('error', function(error) {
			adapter.logError(error);
			vscode.window.showErrorMessage('bower uninstall failed! View Output window for further details');
		}).on('log', function(msg) {
			adapter.log(msg);
		}).on('end', function(installed) {
			var installedPackages = Object.keys(installed);
			if (installedPackages.length === 0){
				vscode.window.showInformationMessage("No packages installed");
				return;
			}
			
			var packages = installedPackages.map(item=> { return { 
				label: item, 
				description: Array.isArray(installed[item]) ? installed[item][0] : installed[item], 
				name: item } });
			displayPackageList(packages);
		}).on('prompt', function(prompts, callback) {
			adapter.prompt(prompts, callback);
		});


	function displayPackageList(packages: vscode.QuickPickItem[]) {
		vscode.window.showQuickPick(packages, { placeHolder: "Select the package to uninstall" }).then(function(item) {
			//displayPackageForUnInstallation(item);
			if (!item) {
				return;
			}
			displayPackageForUnInstallation(item);
		});
	}
	const UNINSTALL_NO_UPDATE = "Uninstall";
	const UNINSTALL = "Uninstall from dependency";
	const UNINSTALL_DEV = "Uninstall from devDependency";
	function displayPackageForUnInstallation(pkg: any) {
		var actions = [
			{ label: UNINSTALL_NO_UPDATE, description: "bower uninstall <name>" },
			{ label: UNINSTALL, description: "Uninstall from bower.json dependencies (bower uninstall <name> --save)" }//,
			// { label: UNINSTALL_DEV, description: "Uninstall from bower.json devDependencies (bower uninstall <name> --save-dev)" }
		];
		vscode.window.showQuickPick(actions, { placeHolder: "Install " + pkg.label }).then(function(action) {
			if (!action){
				return;
			}
			var options: any = {};
			if (action.label === UNINSTALL) {
				options.save = true;
			}
			if (action.label === UNINSTALL_DEV) {
				options["save-dev"] = true;
			}
			
			confirmUninstallPackage(pkg.name, options);
		});
	}

	function confirmUninstallPackage(packageName: string, options: any) {
		vscode.window.showWarningMessage("Are you sure you want to uninstall '" + packageName + "'?", "Yes").then(function(cmd) {
			if (cmd === "Yes") {
				uninstallPackage(packageName, options);
			}
		});
	}
	
	function uninstallPackage(name: string, options: any) {
		bower.commands
			.uninstall([name], options)
			.on('error', function(error) {
				adapter.logError(error);
				vscode.window.showErrorMessage('bower uninstall failed! View Output window for further details');
			}).on('end', function(msg) {
					vscode.window.showInformationMessage("bower package '" + name + "' successfully uninstalled!");
			}).on('log', function(msg) {
				adapter.log(msg);
			}).on('prompt', function(prompts, callback) {
				adapter.prompt(prompts, callback);
			});
	}
}
开发者ID:Tyriar,项目名称:bowerVSCode,代码行数:86,代码来源:uninstall.ts


注:本文中的bower.commands.list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。