Skip to content

Commit

Permalink
Separate test files and example files
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Aug 13, 2021
1 parent 081f1b9 commit 287ed0b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ zx examples/markdown.md
The `zx` can compile `.ts` scripts to `.mjs` and execute them.
```bash
zx examples/typescript.ts
zx script.ts
```
In TypeScript file include the `zx` package to import types:
Expand Down
42 changes: 0 additions & 42 deletions examples/basics.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions examples/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ by zx. Try to run `zx examples/markdown.md`.

```js
await $`whoami`
await $`ls -la ${__dirname}`
await $`echo ${__dirname}`
```

The `__filename` will be pointed to **markdown.md**:
Expand All @@ -17,7 +17,7 @@ console.log(chalk.yellowBright(__filename))
We can use imports here as well:

```js
await import('./basics.mjs')
await import('chalk')
```

A bash code (with `bash` or `sh` language tags) also will be executed:
Expand Down
4 changes: 2 additions & 2 deletions test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import path from 'path'
}

{ // Scripts with no extension are working
await $`node zx.mjs examples/no-extension`
await $`node zx.mjs tests/no-extension`
}

{ // require() is working from stdin
Expand All @@ -94,7 +94,7 @@ import path from 'path'
}

{ // TypeScript scripts are working
await $`node zx.mjs examples/typescript.ts`
await $`node zx.mjs tests/typescript.ts`
}

{ // Quiet mode is working
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/typescript.ts → tests/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {ProcessOutput, ProcessPromise} from '..'
import {ProcessOutput, ProcessPromise} from '../index'

void async function () {
let p: ProcessPromise<ProcessOutput> = $`cat`
Expand Down
15 changes: 7 additions & 8 deletions zx.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,13 @@ async function compile(input) {
let tsc = $`npm_config_yes=true npx -p typescript tsc --target esnext --lib esnext --module esnext --moduleResolution node ${input}`
$.verbose = v

let i = 0, color = [chalk.magentaBright, chalk.cyanBright, chalk.yellowBright,
chalk.greenBright, chalk.blueBright][new Date().getMinutes() % 5],
interval = setInterval(() => {
process.stdout.write(' '
+ color(['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'][i++ % 10])
+ '\r'
)
}, 100)
let i = 0
let interval = setInterval(() => {
process.stdout.write(' '
+ ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'][i++ % 10]
+ '\r'
)
}, 100)

try {
await tsc
Expand Down

0 comments on commit 287ed0b

Please sign in to comment.