Commit 4c8d602

Anton Medvedev <anton@medv.io>
2021-05-07 18:40:17
Remove test function
1 parent a6a7868
examples/basics.mjs
@@ -19,6 +19,4 @@ await $`ls -1 | wc -l`
 let branch = await $`git branch --show-current`
 await $`printf ${branch} | wc`
 
-if (test('-f package.json')) {
-  console.log('Yes')
-}
+await $`test -f package.json`
index.d.ts
@@ -23,8 +23,6 @@ export const $: $
 
 export function cd(path: string)
 
-export function test(cmd: string): boolean
-
 type QuestionOptions = { choices: string[] }
 
 export function question(query: string, options?: QuestionOptions): Promise<string>
index.mjs
@@ -13,7 +13,7 @@
 // limitations under the License.
 
 import {existsSync} from 'fs'
-import {exec, execSync} from 'child_process'
+import {exec} from 'child_process'
 import {promisify} from 'util'
 import {createInterface} from 'readline'
 import {default as nodeFetch} from 'node-fetch'
@@ -84,16 +84,6 @@ export function cd(path) {
   $.cwd = path
 }
 
-export function test(cmd) {
-  if ($.verbose) console.log('$', colorize(`test ${cmd}`))
-  try {
-    execSync(`test ${cmd}`)
-    return true
-  } catch (e) {
-    return false
-  }
-}
-
 export async function question(query, options) {
   let completer = undefined
   if (Array.isArray(options?.choices)) {
README.md
@@ -107,24 +107,6 @@ cd('/tmp')
 await $`pwd` // outputs /tmp 
 ```
 
-### `test()`
-
-Executes `test` command using `execSync` and returns `true` or `false`.
-
-```js
-if (test('-f package.json')) {
-  console.log('Yes')
-}
-```
-
-This is equivalent of next bash code:
-
-```bash
-if test -f package.json; then
-  echo Yes;
-fi
-```
-
 ### `fetch()`
 
 This is a wrapper around [node-fetch](https://www.npmjs.com/package/node-fetch) package.
zx.mjs
@@ -18,13 +18,12 @@ import {join, basename} from 'path'
 import os, {tmpdir} from 'os'
 import {promises as fs} from 'fs'
 import {v4 as uuid} from 'uuid'
-import {$, test, cd, question, fetch, chalk, ProcessOutput} from './index.mjs'
+import {$, cd, question, fetch, chalk, ProcessOutput} from './index.mjs'
 import {version} from './version.js'
 
 Object.assign(global, {
   $,
   cd,
-  test,
   fetch,
   question,
   chalk,