Add File Commands (#571)

* Add File Commands

* pr updates w/ feedback

* run format

* fix lint/format

* slight update with an example in the docs

* pr feedback
This commit is contained in:
Thomas Boop
2020-09-23 11:19:20 -04:00
committed by GitHub
parent da34bfb74d
commit 0759cdc230
6 changed files with 203 additions and 61 deletions
+1 -13
View File
@@ -1,4 +1,5 @@
import * as os from 'os'
import {toCommandValue} from './utils'
// For internal use, subject to change.
@@ -76,19 +77,6 @@ class Command {
}
}
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
export function toCommandValue(input: any): string {
if (input === null || input === undefined) {
return ''
} else if (typeof input === 'string' || input instanceof String) {
return input as string
}
return JSON.stringify(input)
}
function escapeData(s: any): string {
return toCommandValue(s)
.replace(/%/g, '%25')