mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Support silent function calls (#38531)
* Support silent function calls NPM API commands support a second parameter which is boolean: https://github.com/npm/cli/blob/latest/lib/view.js#L76 https://github.com/npm/cli/blob/latest/lib/ls.js#L33 * Update overload types for info command * Revert "Support silent function calls" This reverts commit 4d18bdc187ba836a6ecb37c5e530066c48066915. * Update tests
This commit is contained in:
parent
f00069b980
commit
4a5cd9c56a
18
types/npm/index.d.ts
vendored
18
types/npm/index.d.ts
vendored
@ -37,7 +37,6 @@ declare namespace NPM {
|
||||
//#region Commands Interfaces
|
||||
|
||||
export interface Commands {
|
||||
// Commands
|
||||
install: CommandFunction;
|
||||
uninstall: CommandFunction;
|
||||
cache: CommandFunction;
|
||||
@ -68,7 +67,6 @@ declare namespace NPM {
|
||||
"help-search": CommandFunction;
|
||||
ls: CommandFunction;
|
||||
search: CommandFunction;
|
||||
view: CommandFunction;
|
||||
init: CommandFunction;
|
||||
version: CommandFunction;
|
||||
edit: CommandFunction;
|
||||
@ -82,6 +80,16 @@ declare namespace NPM {
|
||||
bin: CommandFunction;
|
||||
whoami: CommandFunction;
|
||||
|
||||
// view and its aliases
|
||||
view(args: string[], callback: CommandCallback): void;
|
||||
view(args: string[], silent: boolean, callback: CommandCallback): void;
|
||||
info(args: string[], callback: CommandCallback): void;
|
||||
info(args: string[], silent: boolean, callback: CommandCallback): void;
|
||||
show(args: string[], callback: CommandCallback): void;
|
||||
show(args: string[], silent: boolean, callback: CommandCallback): void;
|
||||
v(args: string[], callback: CommandCallback): void;
|
||||
v(args: string[], silent: boolean, callback: CommandCallback): void;
|
||||
|
||||
test: CommandFunction;
|
||||
stop: CommandFunction;
|
||||
start: CommandFunction;
|
||||
@ -103,8 +111,6 @@ declare namespace NPM {
|
||||
isntall: CommandFunction; // install
|
||||
up: CommandFunction; // update
|
||||
c: CommandFunction; // config
|
||||
info: CommandFunction; // view
|
||||
show: CommandFunction; // view
|
||||
find: CommandFunction; // search
|
||||
s: CommandFunction; // search
|
||||
se: CommandFunction; // search
|
||||
@ -119,7 +125,7 @@ declare namespace NPM {
|
||||
t: CommandFunction; // test
|
||||
"find-dupes": CommandFunction; // dedupe
|
||||
ddp: CommandFunction; // dedupe
|
||||
v: CommandFunction; // view
|
||||
|
||||
|
||||
// plumbing
|
||||
build: CommandFunction;
|
||||
@ -129,11 +135,9 @@ declare namespace NPM {
|
||||
visnup: CommandFunction;
|
||||
|
||||
}
|
||||
|
||||
export interface CommandFunction {
|
||||
(args: string[], callback: CommandCallback): void;
|
||||
}
|
||||
|
||||
export interface CommandCallback {
|
||||
(err?: Error, result?: any, result2?: any, result3?: any, result4?: any): void;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Created by using code samples from https://github.com/npm/npm#using-npm-programmatically.
|
||||
*/
|
||||
|
||||
import npm = require("npm");
|
||||
import * as npm from 'npm';
|
||||
|
||||
npm.load({}, function (er) {
|
||||
if (er) {
|
||||
@ -19,9 +19,12 @@ npm.load({}, function (er) {
|
||||
// command succeeded, and data might have some info
|
||||
});
|
||||
|
||||
npm.commands.view(["some", "args"], true, function () {}); // silent: true
|
||||
npm.commands.view(["some", "args"], function () {});
|
||||
|
||||
npm.on("log", function (message: string) {
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
|
||||
npm.config.set('audit', false);
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user