mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-30 23:30:06 +00:00
Merge pull request #34683 from msanguineti/shelljs
[shelljs] Added construct and function signatures for shelljs/ShellString
This commit is contained in:
46
types/shelljs/index.d.ts
vendored
46
types/shelljs/index.d.ts
vendored
@@ -6,6 +6,7 @@
|
||||
// Paul Huynh <https://github.com/pheromonez>
|
||||
// Alexander Futász <https://github.com/aldafu>
|
||||
// ExE Boss <https://github.com/ExE-Boss>
|
||||
// Mirco Sanguineti <https://github.com/msanguineti>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
@@ -965,6 +966,51 @@ export type ShellString = string & ShellReturnValue;
|
||||
|
||||
export type ShellArray = string[] & ShellReturnValue;
|
||||
|
||||
export interface ShellStringConstructor {
|
||||
/**
|
||||
* Wraps a string (or array) value. This has all the string (or array) methods,
|
||||
* but also exposes extra methods: `.to()`, `.toEnd()`, and all the pipe-able
|
||||
* methods (ex. `.cat()`, `.grep()`, etc.).
|
||||
*
|
||||
* This can be easily converted into a string by calling `.toString()`.
|
||||
*
|
||||
* This type also exposes the corresponding command's stdout, stderr, and return status
|
||||
* code via the `.stdout` (string), `.stderr` (string), and `.code` (number) properties
|
||||
* respectively.
|
||||
*
|
||||
* Construct signature allows for:
|
||||
*
|
||||
* var foo = new ShellString('hello world');
|
||||
*
|
||||
* as per example in shelljs docs:
|
||||
* https://github.com/shelljs/shelljs#shellstringstr
|
||||
*
|
||||
* @param value The string value to wrap.
|
||||
* @return A string-like object with special methods.
|
||||
*/
|
||||
new(value: string): ShellString;
|
||||
new(value: string[]): ShellArray;
|
||||
|
||||
/**
|
||||
* Wraps a string (or array) value. This has all the string (or array) methods,
|
||||
* but also exposes extra methods: `.to()`, `.toEnd()`, and all the pipe-able
|
||||
* methods (ex. `.cat()`, `.grep()`, etc.).
|
||||
*
|
||||
* This can be easily converted into a string by calling `.toString()`.
|
||||
*
|
||||
* This type also exposes the corresponding command's stdout, stderr, and return status
|
||||
* code via the `.stdout` (string), `.stderr` (string), and `.code` (number) properties
|
||||
* respectively.
|
||||
*
|
||||
* @param value The string value to wrap.
|
||||
* @return A string-like object with special methods.
|
||||
*/
|
||||
(value: string): ShellString;
|
||||
(value: string[]): ShellArray;
|
||||
}
|
||||
|
||||
export const ShellString: ShellStringConstructor;
|
||||
|
||||
export interface ChmodFunction {
|
||||
/**
|
||||
* Alters the permissions of a file or directory by either specifying the absolute
|
||||
|
||||
1
types/shelljs/make.d.ts
vendored
1
types/shelljs/make.d.ts
vendored
@@ -39,4 +39,5 @@ declare global {
|
||||
const tempdir: typeof shelljs.tempdir;
|
||||
const touch: typeof shelljs.touch;
|
||||
const uniq: typeof shelljs.uniq;
|
||||
const ShellString: typeof shelljs.ShellString;
|
||||
}
|
||||
|
||||
@@ -196,3 +196,9 @@ shell
|
||||
.ls("dir")
|
||||
.grep(/^stuff/)
|
||||
.head({"-n": 5}).stdout;
|
||||
|
||||
const foo = new shell.ShellString('hello world');
|
||||
const farr = new shell.ShellString(['hello', 'world']);
|
||||
|
||||
const boo = shell.ShellString('hello world');
|
||||
const barr = shell.ShellString(['hello', 'world']);
|
||||
|
||||
Reference in New Issue
Block a user