本文整理汇总了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);
}));
示例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);
});
}
示例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);
});
}
}
示例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);
});
}
}