microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e45838cbf8bb84beab7d36042bcdbc57fe0319c8

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/typings/shelljs/shelljs.d.ts

536lines · modecode

1// Type definitions for ShellJS v0.3.0
2// Project: http://shelljs.org
3// Definitions by: Niklas Mollenhauer <https://github.com/nikeee>
4// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
6
7///<reference path="../node/node.d.ts"/>
8
9declare module "shelljs"
10{
11 import child = require("child_process");
12
13 /**
14 * Changes to directory dir for the duration of the script
15 * @param {string} dir Directory to change in.
16 */
17 export function cd(dir: string): void;
18
19 /**
20 * Returns the current directory.
21 * @return {string} The current directory.
22 */
23 export function pwd(): string;
24
25 /**
26 * Returns array of files in the given path, or in current directory if no path provided.
27 * @param {string[]} ...paths Paths to search.
28 * @return {string[]} An array of files in the given path(s).
29 */
30 export function ls(...paths: string[]): string[];
31
32 /**
33 * Returns array of files in the given path, or in current directory if no path provided.
34 * @param {string} options Available options: -R (recursive), -A (all files, include files beginning with ., except for . and ..)
35 * @param {string[]} ...paths Paths to search.
36 * @return {string[]} An array of files in the given path(s).
37 */
38 export function ls(options: string, ...paths: string[]): string[];
39
40 /**
41 * Returns array of files in the given path, or in current directory if no path provided.
42 * @param {string[]} paths Paths to search.
43 * @return {string[]} An array of files in the given path(s).
44 */
45 export function ls(paths: string[]): string[];
46
47 /**
48 * Returns array of files in the given path, or in current directory if no path provided.
49 * @param {string} options Available options: -R (recursive), -A (all files, include files beginning with ., except for . and ..)
50 * @param {string[]} paths Paths to search.
51 * @return {string[]} An array of files in the given path(s).
52 */
53 export function ls(options: string, paths: string[]): string[];
54
55 /**
56 * Returns array of all files (however deep) in the given paths.
57 * @param {string[]} ...path The path(s) to search.
58 * @return {string[]} An array of all files (however deep) in the given path(s).
59 */
60 export function find(...path: string[]): string[];
61
62 /**
63 * Returns array of all files (however deep) in the given paths.
64 * @param {string[]} path The path(s) to search.
65 * @return {string[]} An array of all files (however deep) in the given path(s).
66 */
67 export function find(path: string[]): string[];
68
69 /**
70 * Copies files. The wildcard * is accepted.
71 * @param {string} source The source.
72 * @param {string} dest The destination.
73 */
74 export function cp(source: string, dest: string): void;
75
76 /**
77 * Copies files. The wildcard * is accepted.
78 * @param {string[]} source The source.
79 * @param {string} dest The destination.
80 */
81 export function cp(source: string[], dest: string): void;
82
83 /**
84 * Copies files. The wildcard * is accepted.
85 * @param {string} options Available options: -f (force), -r, -R (recursive)
86 * @param {strin]} source The source.
87 * @param {string} dest The destination.
88 */
89 export function cp(options: string, source: string, dest: string): void;
90
91 /**
92 * Copies files. The wildcard * is accepted.
93 * @param {string} options Available options: -f (force), -r, -R (recursive)
94 * @param {string[]} source The source.
95 * @param {string} dest The destination.
96 */
97 export function cp(options: string, source: string[], dest: string): void;
98
99 /**
100 * Removes files. The wildcard * is accepted.
101 * @param {string[]} ...files Files to remove.
102 */
103 export function rm(...files: string[]): void;
104
105 /**
106 * Removes files. The wildcard * is accepted.
107 * @param {string[]} files Files to remove.
108 */
109 export function rm(files: string[]): void;
110
111 /**
112 * Removes files. The wildcard * is accepted.
113 * @param {string} options Available options: -f (force), -r, -R (recursive)
114 * @param {string[]} ...files Files to remove.
115 */
116 export function rm(options: string, ...files: string[]): void;
117
118 /**
119 * Removes files. The wildcard * is accepted.
120 * @param {string} options Available options: -f (force), -r, -R (recursive)
121 * @param {string[]} ...files Files to remove.
122 */
123 export function rm(options: string, files: string[]): void;
124
125 /**
126 * Moves files. The wildcard * is accepted.
127 * @param {string} source The source.
128 * @param {string} dest The destination.
129 */
130 export function mv(source: string, dest: string): void;
131
132 /**
133 * Moves files. The wildcard * is accepted.
134 * @param {string[]} source The source.
135 * @param {string} dest The destination.
136 */
137 export function mv(source: string[], dest: string): void;
138
139 /**
140 * Creates directories.
141 * @param {string[]} ...dir Directories to create.
142 */
143 export function mkdir(...dir: string[]): void;
144
145 /**
146 * Creates directories.
147 * @param {string[]} dir Directories to create.
148 */
149 export function mkdir(dir: string[]): void;
150
151 /**
152 * Creates directories.
153 * @param {string} options Available options: p (full paths, will create intermediate dirs if necessary)
154 * @param {string[]} ...dir The directories to create.
155 */
156 export function mkdir(options: string, ...dir: string[]): void;
157
158 /**
159 * Creates directories.
160 * @param {string} options Available options: p (full paths, will create intermediate dirs if necessary)
161 * @param {string[]} dir The directories to create.
162 */
163 export function mkdir(options: string, dir: string[]): void;
164
165 /**
166 * Evaluates expression using the available primaries and returns corresponding value.
167 * @param {string} option '-b': true if path is a block device; '-c': true if path is a character device; '-d': true if path is a directory; '-e': true if path exists; '-f': true if path is a regular file; '-L': true if path is a symboilc link; '-p': true if path is a pipe (FIFO); '-S': true if path is a socket
168 * @param {string} path The path.
169 * @return {boolean} See option parameter.
170 */
171 export function test(option: string, path: string): boolean;
172
173 /**
174 * Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). Wildcard * accepted.
175 * @param {string[]} ...files Files to use.
176 * @return {string} A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
177 */
178 export function cat(...files: string[]): string;
179
180 /**
181 * Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). Wildcard * accepted.
182 * @param {string[]} files Files to use.
183 * @return {string} A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
184 */
185 export function cat(files: string[]): string;
186
187
188 // Does not work yet.
189 export interface String
190 {
191 /**
192 * Analogous to the redirection operator > in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc). Like Unix redirections, to() will overwrite any existing file!
193 * @param {string} file The file to use.
194 */
195 to(file: string): void;
196
197 /**
198 * Analogous to the redirect-and-append operator >> in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc).
199 * @param {string} file The file to append to.
200 */
201 toEnd(file: string): void;
202 }
203
204 /**
205 * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
206 * @param {RegExp} searchRegex The regular expression to use for search.
207 * @param {string} replacement The replacement.
208 * @param {string} file The file to process.
209 * @return {string} The new string after replacement.
210 */
211 export function sed(searchRegex: RegExp, replacement: string, file: string): string;
212
213 /**
214 * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
215 * @param {string} searchRegex The regular expression to use for search.
216 * @param {string} replacement The replacement.
217 * @param {string} file The file to process.
218 * @return {string} The new string after replacement.
219 */
220 export function sed(searchRegex: string, replacement: string, file: string): string;
221
222 /**
223 * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
224 * @param {string} options Available options: -i (Replace contents of 'file' in-place. Note that no backups will be created!)
225 * @param {RegExp} searchRegex The regular expression to use for search.
226 * @param {string} replacement The replacement.
227 * @param {string} file The file to process.
228 * @return {string} The new string after replacement.
229 */
230 export function sed(options: string, searchRegex: RegExp, replacement: string, file: string): string;
231
232 /**
233 * Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
234 * @param {string} options Available options: -i (Replace contents of 'file' in-place. Note that no backups will be created!)
235 * @param {string} searchRegex The regular expression to use for search.
236 * @param {string} replacement The replacement.
237 * @param {string} file The file to process.
238 * @return {string} The new string after replacement.
239 */
240 export function sed(options: string, searchRegex: string, replacement: string, file: string): string;
241
242 /**
243 * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
244 * @param {RegExp} regex_filter The regular expression to use.
245 * @param {string[]} ...files The files to process.
246 * @return {string} Returns a string containing all lines of the file that match the given regex_filter.
247 */
248 export function grep(regex_filter: RegExp, ...files: string[]): string;
249
250 /**
251 * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
252 * @param {RegExp} regex_filter The regular expression to use.
253 * @param {string[]} ...files The files to process.
254 * @return {string} Returns a string containing all lines of the file that match the given regex_filter.
255 */
256 export function grep(regex_filter: RegExp, files: string[]): string;
257
258 /**
259 * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
260 * @param {string} options Available options: -v (Inverse the sense of the regex and print the lines not matching the criteria.)
261 * @param {string} regex_filter The regular expression to use.
262 * @param {string[]} ...files The files to process.
263 * @return {string} Returns a string containing all lines of the file that match the given regex_filter.
264 */
265 export function grep(options: string, regex_filter: string, ...files: string[]): string;
266
267 /**
268 * Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
269 * @param {string} options Available options: -v (Inverse the sense of the regex and print the lines not matching the criteria.)
270 * @param {string} regex_filter The regular expression to use.
271 * @param {string[]} files The files to process.
272 * @return {string} Returns a string containing all lines of the file that match the given regex_filter.
273 */
274 export function grep(options: string, regex_filter: string, files: string[]): string;
275
276 /**
277 * Searches for command in the system's PATH. On Windows looks for .exe, .cmd, and .bat extensions.
278 * @param {string} command The command to search for.
279 * @return {string} Returns string containing the absolute path to the command.
280 */
281 export function which(command: string): string;
282
283 /**
284 * Prints string to stdout, and returns string with additional utility methods like .to().
285 * @param {string[]} ...text The text to print.
286 * @return {string} Returns the string that was passed as argument.
287 */
288 export function echo(...text: string[]): string;
289
290 /**
291 * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
292 * @param {"+N"} dir Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
293 * @return {string[]} Returns an array of paths in the stack.
294 */
295 export function pushd(dir: "+N"): string[];
296
297 /**
298 * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
299 * @param {"-N"} dir Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
300 * @return {string[]} Returns an array of paths in the stack.
301 */
302 export function pushd(dir: "-N"): string[];
303
304 /**
305 * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
306 * @param {string} dir Makes the current working directory be the top of the stack, and then executes the equivalent of cd dir.
307 * @return {string[]} Returns an array of paths in the stack.
308 */
309 export function pushd(dir: string): string[];
310
311 /**
312 * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
313 * @param {string} options Available options: -n (Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated)
314 * @param {"+N"} dir Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
315 * @return {string[]} Returns an array of paths in the stack.
316 */
317 export function pushd(options: string, dir: "+N"): string[];
318
319 /**
320 * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
321 * @param {string} options Available options: -n (Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated)
322 * @param {"-N"} dir Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
323 * @return {string[]} Returns an array of paths in the stack.
324 */
325 export function pushd(options: string, dir: "-N"): string[];
326
327 /**
328 * Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
329 * @param {string} options Available options: -n (Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated)
330 * @param {string} dir Makes the current working directory be the top of the stack, and then executes the equivalent of cd dir.
331 * @return {string[]} Returns an array of paths in the stack.
332 */
333 export function pushd(options: string, dir: string): string[];
334
335 /**
336 * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
337 * @param {"+N"} dir Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
338 * @return {string[]} Returns an array of paths in the stack.
339 */
340 export function popd(dir: "+N"): string[];
341
342 /**
343 * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
344 * @return {string[]} Returns an array of paths in the stack.
345 */
346 export function popd(): string[];
347
348 /**
349 * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
350 * @param {"-N"} dir Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
351 * @return {string[]} Returns an array of paths in the stack.
352 */
353 export function popd(dir: "-N"): string[];
354
355 /**
356 * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
357 * @param {string} dir You can only use -N and +N.
358 * @return {string[]} Returns an array of paths in the stack.
359 */
360 export function popd(dir: string): string[];
361
362 /**
363 * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
364 * @param {string} options Available options: -n (Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated)
365 * @param {"+N"} dir Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
366 * @return {string[]} Returns an array of paths in the stack.
367 */
368 export function popd(options: string, dir: "+N"): string[];
369
370 /**
371 * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
372 * @param {string} options Available options: -n (Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated)
373 * @param {"-N"} dir Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
374 * @return {string[]} Returns an array of paths in the stack.
375 */
376 export function popd(options: string, dir: "-N"): string[];
377
378 /**
379 * When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
380 * @param {string} options Available options: -n (Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated)
381 * @param {string} dir You can only use -N and +N.
382 * @return {string[]} Returns an array of paths in the stack.
383 */
384 export function popd(options: string, dir: string): string[];
385
386 /**
387 * Clears the directory stack by deleting all of the elements.
388 * @param {"-c"} options Clears the directory stack by deleting all of the elements.
389 * @return {string[]} Returns an array of paths in the stack, or a single path if +N or -N was specified.
390 */
391 export function dirs(options: "-c"): string[];
392
393 /**
394 * Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
395 * @param {"+N"} options Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero.
396 * @return {string[]} Returns an array of paths in the stack, or a single path if +N or -N was specified.
397 */
398 export function dirs(options: "+N"): string;
399
400 /**
401 * Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
402 * @param {"-N"} options Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
403 * @return {string[]} Returns an array of paths in the stack, or a single path if +N or -N was specified.
404 */
405 export function dirs(options: "-N"): string;
406
407 /**
408 * Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
409 * @param {string} options Available options: -c, -N, +N. You can only use those.
410 * @return {any} Returns an array of paths in the stack, or a single path if +N or -N was specified.
411 */
412 export function dirs(options: string): any;
413
414 /**
415 * Links source to dest. Use -f to force the link, should dest already exist.
416 * @param {string} source The source.
417 * @param {string} dest The destination.
418 */
419 export function ln(source: string, dest: string): void;
420
421 /**
422 * Links source to dest. Use -f to force the link, should dest already exist.
423 * @param {string} options Available options: s (symlink), f (force)
424 * @param {string} source The source.
425 * @param {string} dest The destination.
426 */
427 export function ln(options: string, source: string, dest: string): void;
428
429 /**
430 * Exits the current process with the given exit code.
431 * @param {number} code The exit code.
432 */
433 export function exit(code: number): void;
434
435 /**
436 * Object containing environment variables (both getter and setter). Shortcut to process.env.
437 */
438 export var env: { [key: string]: string };
439
440 /**
441 * Executes the given command synchronously.
442 * @param {string} command The command to execute.
443 * @return {ExecOutputReturnValue} Returns an object containing the return code and output as string.
444 */
445 export function exec(command: string): ExecOutputReturnValue;
446 /**
447 * Executes the given command synchronously.
448 * @param {string} command The command to execute.
449 * @param {ExecOptions} options Silence and synchronous options.
450 * @return {ExecOutputReturnValue | child.ChildProcess} Returns an object containing the return code and output as string, or if {async:true} was passed, a ChildProcess.
451 */
452 export function exec(command: string, options: ExecOptions): ExecOutputReturnValue | child.ChildProcess;
453 /**
454 * Executes the given command synchronously.
455 * @param {string} command The command to execute.
456 * @param {ExecOptions} options Silence and synchronous options.
457 * @param {ExecCallback} callback Receives code and output asynchronously.
458 */
459 export function exec(command: string, options: ExecOptions, callback: ExecCallback): child.ChildProcess;
460 /**
461 * Executes the given command synchronously.
462 * @param {string} command The command to execute.
463 * @param {ExecCallback} callback Receives code and output asynchronously.
464 */
465 export function exec(command: string, callback: ExecCallback): child.ChildProcess;
466
467 export interface ExecCallback {
468 (code: number, output: string): any;
469 }
470
471 export interface ExecOptions {
472 silent?: boolean;
473 async?: boolean;
474 }
475
476 export interface ExecOutputReturnValue
477 {
478 code: number;
479 output: string;
480 }
481
482 /**
483 * Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions:
484 * - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
485 * - There is no "quiet" option since default behavior is to run silent.
486 * @param {number} octalMode The access mode. Octal.
487 * @param {string} file The file to use.
488 */
489 export function chmod(octalMode: number, file: string): void;
490
491 /**
492 * Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions:
493 * - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
494 * - There is no "quiet" option since default behavior is to run silent.
495 * @param {string} mode The access mode. Can be an octal string or a symbolic mode string.
496 * @param {string} file The file to use.
497 */
498 export function chmod(mode: string, file: string): void;
499
500 // Non-Unix commands
501
502 /**
503 * Searches and returns string containing a writeable, platform-dependent temporary directory. Follows Python's tempfile algorithm.
504 * @return {string} The temp file path.
505 */
506 export function tempdir(): string;
507
508 /**
509 * Tests if error occurred in the last command.
510 * @return {string} Returns null if no error occurred, otherwise returns string explaining the error
511 */
512 export function error(): string;
513
514 // Configuration
515
516 interface ShellConfig
517 {
518 /**
519 * Suppresses all command output if true, except for echo() calls. Default is false.
520 * @type {boolean}
521 */
522 silent: boolean;
523
524 /**
525 * If true the script will die on errors. Default is false.
526 * @type {boolean}
527 */
528 fatal: boolean;
529 }
530
531 /**
532 * The shelljs configuration.
533 * @type {ShellConfig}
534 */
535 export var config: ShellConfig;
536}