Fixed ShellJS.exec() definition in .d.ts.

This commit is contained in:
Alan
2015-01-26 00:23:24 -05:00
parent e5d5d87e49
commit ce14ae27a0
2 changed files with 62 additions and 21 deletions

View File

@@ -85,8 +85,34 @@ shell.ln("-sf", "file", "existing");
var testPath = shell.env["path"];
import child = require("child_process");
var version = shell.exec("node --version").output;
var version2 = <shell.ExecOutputReturnValue>shell.exec("node --version", { async: false });
var output = version2.output;
var asyncVersion3 = <child.ChildProcess>shell.exec("node --version", { async: true });
var pid = asyncVersion3.pid;
shell.exec("node --version", { silent: true }, function (code, output) {
var version = output;
});
shell.exec("node --version", { silent: true, async: true }, function (code, output) {
var version = output;
});
shell.exec("node --version", function (code, output) {
var version = output;
});
shell.exec("node --version", function (code: number) {
var num: number = code;
});
var childProc = shell.exec("node --version", function (code: number) {
var num: number = code;
});
var pid = childProc.pid;
shell.chmod(755, "/Users/brandon");
shell.chmod("755", "/Users/brandon"); // same as above
shell.chmod("u+x", "/Users/brandon");

57
shelljs/shelljs.d.ts vendored
View File

@@ -8,6 +8,8 @@
declare module "shelljs"
{
import child = require("child_process");
/**
* Changes to directory dir for the duration of the script
* @param {string} dir Directory to change in.
@@ -434,31 +436,44 @@ declare module "shelljs"
* Object containing environment variables (both getter and setter). Shortcut to process.env.
*/
export var env: { [key: string]: string };
/*
// Not yet implemented due to implementation issues (constant overloads and return types).
// See: https://github.com/arturadib/shelljs#execcommand--options--callback
export function exec(command: string, options: ExecOptions, callback: (code: number, output: string) => any): any;
export function exec(command: string, options: ExecOptions): any;
interface ExecOptions
{
silent: boolean;
async: boolean;
}
*/
/**
* Executes the given command synchronously.
* @param {string} command The commadn to execute.
* @return {ExecReturnValue} Returns an object containing the return code and output as string.
* @param {string} command The command to execute.
* @return {ExecOutputReturnValue} Returns an object containing the return code and output as string.
*/
export function exec(command: string): ExecReturnValue;
export function exec(command: string): ExecOutputReturnValue;
/**
* Executes the given command synchronously.
* @param {string} command The command to execute.
* @param {ExecOptions} options Silence and synchronous options.
* @return {ExecOutputReturnValue | child.ChildProcess} Returns an object containing the return code and output as string, or if {async:true} was passed, a ChildProcess.
*/
export function exec(command: string, options: ExecOptions): ExecOutputReturnValue | child.ChildProcess;
/**
* Executes the given command synchronously.
* @param {string} command The command to execute.
* @param {ExecOptions} options Silence and synchronous options.
* @param {ExecCallback} callback Receives code and output asynchronously.
*/
export function exec(command: string, options: ExecOptions, callback: ExecCallback): child.ChildProcess;
/**
* Executes the given command synchronously.
* @param {string} command The command to execute.
* @param {ExecCallback} callback Receives code and output asynchronously.
*/
export function exec(command: string, callback: ExecCallback): child.ChildProcess;
interface ExecReturnValue
export interface ExecCallback {
(code: number, output: string): any;
}
export interface ExecOptions {
silent?: boolean;
async?: boolean;
}
export interface ExecOutputReturnValue
{
code: number;
output: string;