mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Merge pull request #1887 from panopticoncentral/master
Add missing methods to create npm publish tasks, added definitions for nomnom
This commit is contained in:
11
jake/jake.d.ts
vendored
11
jake/jake.d.ts
vendored
@@ -22,7 +22,6 @@ declare function desc(description:string): void;
|
||||
*/
|
||||
declare function directory(name:string): jake.DirectoryTask;
|
||||
|
||||
|
||||
/**
|
||||
* Causes Jake execution to abort with an error. Allows passing an optional error code, which will be used to set the exit-code of exiting process.
|
||||
* @param err The error to thow when aborting execution. If this argument is an Error object, it will simply be thrown. If a String, it will be used as the error-message. (If it is a multi-line String, the first line will be used as the Error message, and the remaining lines will be used as the error-stack.)
|
||||
@@ -57,6 +56,15 @@ declare function task(name:string, prereqs?:string[], action?:(...params:any[])=
|
||||
declare function task(name:string, action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task;
|
||||
declare function task(name:string, opts?:jake.TaskOptions, action?:(...params:any[])=>any): jake.Task;
|
||||
|
||||
/**
|
||||
* @param name The name of the NpmPublishTask
|
||||
* @param packageFiles The files to include in the package
|
||||
* @param definition A function that creates the package definition
|
||||
*/
|
||||
declare function npmPublishTask(name:string, packageFiles:string[]): jake.NpmPublishTask;
|
||||
declare function npmPublishTask(name:string, definition?:()=>void): jake.NpmPublishTask;
|
||||
|
||||
|
||||
declare module jake{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -368,6 +376,7 @@ declare module jake{
|
||||
|
||||
export class NpmPublishTask{
|
||||
constructor(name:string, packageFiles:string[]);
|
||||
constructor(name:string, definition?:()=>void);
|
||||
}
|
||||
|
||||
export function addListener(event: string, listener: Function): NodeEventEmitter;
|
||||
|
||||
122
nomnom/nomnom-tests.ts
Normal file
122
nomnom/nomnom-tests.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
// https://github.com/harthur/nomnom
|
||||
/// <reference path="nomnom.d.ts" />
|
||||
|
||||
import nomnom = require("nomnom");
|
||||
|
||||
var opts1 = nomnom
|
||||
.option('debug', {
|
||||
abbr: 'd',
|
||||
flag: true,
|
||||
help: 'Print debugging info'
|
||||
})
|
||||
.option('config', {
|
||||
abbr: 'c',
|
||||
default: 'config.json',
|
||||
help: 'JSON file with tests to run'
|
||||
})
|
||||
.option('version', {
|
||||
flag: true,
|
||||
help: 'print version and exit',
|
||||
callback: () => "version 1.2.4"
|
||||
})
|
||||
.parse();
|
||||
|
||||
if (opts1.debug) {
|
||||
}
|
||||
|
||||
var opts2 = nomnom.parse();
|
||||
|
||||
var url = opts2[0]; // get the first positional arg
|
||||
var file = opts2.file; // see if --file was specified
|
||||
var verbose = opts2.v; // see if -v was specified
|
||||
var extras = opts2._; // get an array of the unmatched, positional args
|
||||
|
||||
var parser = nomnom;
|
||||
|
||||
function runBrowser(url: string): void {
|
||||
}
|
||||
|
||||
function runSanity(filename: string): void {
|
||||
}
|
||||
|
||||
parser.command('browser')
|
||||
.callback(opts => {
|
||||
runBrowser(opts.url);
|
||||
})
|
||||
.help("run browser tests");
|
||||
|
||||
parser.command('sanity')
|
||||
.option('outfile', {
|
||||
abbr: 'o',
|
||||
help: "file to write results to"
|
||||
})
|
||||
.option('config', {
|
||||
abbr: 'c',
|
||||
default: 'config.json',
|
||||
help: "json manifest of tests to run"
|
||||
})
|
||||
.callback(opts => {
|
||||
runSanity(opts.filename);
|
||||
})
|
||||
.help("run the sanity tests");
|
||||
|
||||
parser.parse();
|
||||
|
||||
var opts3 = nomnom
|
||||
.script("runtests")
|
||||
.options({
|
||||
path: {
|
||||
position: 0,
|
||||
help: "Test file to run",
|
||||
list: true
|
||||
},
|
||||
config: {
|
||||
abbr: 'c',
|
||||
metavar: 'FILE',
|
||||
help: "Config file with tests to run"
|
||||
},
|
||||
debug: {
|
||||
abbr: 'd',
|
||||
flag: true,
|
||||
help: "Print debugging info"
|
||||
}
|
||||
}).parse();
|
||||
|
||||
nomnom.option('debug', {
|
||||
abbr: 'd'
|
||||
});
|
||||
|
||||
nomnom.option('numLines', {
|
||||
abbr: 'n',
|
||||
full: 'num-lines'
|
||||
});
|
||||
|
||||
nomnom.option('config', {
|
||||
flag: true
|
||||
});
|
||||
|
||||
nomnom.option('count', {
|
||||
callback: count => {
|
||||
if (count != parseInt(count))
|
||||
return "count must be an integer";
|
||||
}
|
||||
});
|
||||
|
||||
nomnom.option('debug', {
|
||||
abbr: 'd',
|
||||
flag: true,
|
||||
help: "Print debugging info"
|
||||
});
|
||||
|
||||
nomnom.options({
|
||||
debug: {
|
||||
abbr: 'd',
|
||||
flag: true,
|
||||
help: "Print debugging info"
|
||||
},
|
||||
fruit: {
|
||||
help: "Fruit to buy"
|
||||
}
|
||||
});
|
||||
|
||||
var opts4 = nomnom.parse(["-xvf", "--atomic=true"]);
|
||||
1
nomnom/nomnom-tests.ts.tscparams
Normal file
1
nomnom/nomnom-tests.ts.tscparams
Normal file
@@ -0,0 +1 @@
|
||||
""
|
||||
225
nomnom/nomnom.d.ts
vendored
Normal file
225
nomnom/nomnom.d.ts
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
// Type definitions for nomnom
|
||||
// Project: https://github.com/harthur/nomnom
|
||||
// Definitions by: Paul Vick <https://github.com/panopticoncentral>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "nomnom"
|
||||
{
|
||||
/**
|
||||
* The command-line parser.
|
||||
*/
|
||||
module Parser
|
||||
{
|
||||
/**
|
||||
* A command-line option.
|
||||
*/
|
||||
export interface Option
|
||||
{
|
||||
/**
|
||||
* The abbreviated name of the option.
|
||||
*/
|
||||
abbr?: string;
|
||||
|
||||
/**
|
||||
* The full name of the option.
|
||||
*/
|
||||
full?: string;
|
||||
|
||||
/**
|
||||
* Whether the option is a flag.
|
||||
*/
|
||||
flag?: boolean;
|
||||
|
||||
/**
|
||||
* A string to be used in the usage printout.
|
||||
*/
|
||||
metavar?: string;
|
||||
|
||||
/**
|
||||
* A shorthand for abbr, full, and metavar.
|
||||
*/
|
||||
string?: string;
|
||||
|
||||
/**
|
||||
* A help string for the option.
|
||||
*/
|
||||
help?: string;
|
||||
|
||||
/**
|
||||
* The default value of the option.
|
||||
*/
|
||||
default?: any;
|
||||
|
||||
/**
|
||||
* A callback for the option.
|
||||
*/
|
||||
callback?: (option: any) => string;
|
||||
|
||||
/**
|
||||
* The position of the option if it's a positional argument.
|
||||
*/
|
||||
position?: number;
|
||||
|
||||
/**
|
||||
* Whether the option is a list.
|
||||
*/
|
||||
list?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the option is required.
|
||||
*/
|
||||
required?: boolean;
|
||||
|
||||
/**
|
||||
* The choices for the option.
|
||||
*/
|
||||
choices?: string[];
|
||||
|
||||
/**
|
||||
* If you don't want the option JSON-parsed, specify type "string".
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
/**
|
||||
* Whether the option is hidden.
|
||||
*/
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A command-line command specification.
|
||||
*/
|
||||
export interface Command
|
||||
{
|
||||
/**
|
||||
* The name of the command.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Sets the options of the command.
|
||||
* @param specs The specifications of the options.
|
||||
* @returns The command.
|
||||
*/
|
||||
options(specs: { [index: string]: Option }): Command;
|
||||
|
||||
/**
|
||||
* Sets an option of the command.
|
||||
* @param name The name of the option.
|
||||
* @param spec The specifiction of the option.
|
||||
* @returns The command.
|
||||
*/
|
||||
option(name: string, spec: Option): Command;
|
||||
|
||||
/**
|
||||
* Sets a callback for the command.
|
||||
* @param func The callback function.
|
||||
* @returns The command.
|
||||
*/
|
||||
callback(func: (options: any) => void): Command;
|
||||
|
||||
/**
|
||||
* Sets the help string for the command.
|
||||
* @param help The help string.
|
||||
* @returns The command.
|
||||
*/
|
||||
help(help: string): Command;
|
||||
|
||||
/**
|
||||
* Sets the usage string for the command.
|
||||
* @param usage The usage string.
|
||||
* @returns The command.
|
||||
*/
|
||||
usage(usage: string): Command;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The command-line parser.
|
||||
*/
|
||||
interface Parser
|
||||
{
|
||||
/**
|
||||
* Returns the parser.
|
||||
*/
|
||||
(): Parser;
|
||||
|
||||
/**
|
||||
* Creates a new command.
|
||||
* @param name The name of the command.
|
||||
* @returns The new command.
|
||||
*/
|
||||
command(name: string): Parser.Command;
|
||||
|
||||
/**
|
||||
* Returns the commmand representing no command.
|
||||
* @returns The command representing no command.
|
||||
*/
|
||||
nocommand(): Parser.Command;
|
||||
|
||||
/**
|
||||
* Sets the options of the command-line.
|
||||
* @param specs The specifications of the options.
|
||||
* @returns The command-line parser.
|
||||
*/
|
||||
options(specs: { [index: string]: Parser.Option }): Parser;
|
||||
|
||||
/**
|
||||
* Sets an option of the command-line.
|
||||
* @param name The name of the option.
|
||||
* @param spec The specifiction of the option.
|
||||
* @returns The command-line parser.
|
||||
*/
|
||||
option(name: string, spec: Parser.Option): Parser;
|
||||
|
||||
/**
|
||||
* Sets the usage string for the command-line.
|
||||
* @param usage The usage string.
|
||||
* @returns The command-line parser.
|
||||
*/
|
||||
usage(usage: string): Parser;
|
||||
|
||||
/**
|
||||
* Provides a printer to the command-line processor.
|
||||
* @param print The print function to use.
|
||||
* @returns The command-line parser.
|
||||
*/
|
||||
printer(print: (message: string, code?: number) => void): Parser;
|
||||
|
||||
/**
|
||||
* Sets the name of the script.
|
||||
* @param script The script name.
|
||||
* @returns The command-line parser.
|
||||
*/
|
||||
script(script: string): Parser;
|
||||
|
||||
/**
|
||||
* Sets the help string for the command-line.
|
||||
* @param help The help string.
|
||||
* @returns The command-line parser.
|
||||
*/
|
||||
help(help: string): Parser;
|
||||
|
||||
/**
|
||||
* Sets the command-line parser not to use colors.
|
||||
* @returns The command-line parser.
|
||||
*/
|
||||
nocolors(): Parser;
|
||||
|
||||
/**
|
||||
* Parses the command-line.
|
||||
* @param argv The command-line arguments.
|
||||
* @returns The parsed command-line.
|
||||
*/
|
||||
nom(argv?: string[]): any;
|
||||
|
||||
/**
|
||||
* Parses the command-line.
|
||||
* @param argv The command-line arguments.
|
||||
* @returns The parsed command-line.
|
||||
*/
|
||||
parse(argv?: string[]): any;
|
||||
}
|
||||
|
||||
export = Parser;
|
||||
}
|
||||
Reference in New Issue
Block a user