Skip to content

Commit

Permalink
Rewrite all the code in TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-zheng-an committed Mar 2, 2019
1 parent 704facf commit 069bb0c
Show file tree
Hide file tree
Showing 10 changed files with 378 additions and 165 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules/
/npm-debug.log

.nyc_output/
/.nyc_output/
/lib/
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Or you can use this shorthand:
gulp.task('greet', shell.task('echo Hello, World!'))
```

You can find more examples in the [gulpfile](https://github.com/sun-zheng-an/gulp-shell/blob/master/gulpfile.js) of this project.
You can find more examples in the [gulpfile](https://github.com/sun-zheng-an/gulp-shell/blob/master/gulpfile.ts) of this project.

**WARNING**: Running commands like ~~`gulp.src('').pipe(shell('whatever'))`~~ is [considered as an anti-pattern](https://github.com/sun-zheng-an/gulp-shell/issues/55). **PLEASE DON'T DO THAT ANYMORE**.

Expand All @@ -43,23 +43,23 @@ You can find more examples in the [gulpfile](https://github.com/sun-zheng-an/gul

#### commands

type: `Array` or `String`
type: `string` or `Array<string>`

A command can be a [template][] which can be interpolated by some [file][] info (e.g. `file.path`).

**WARNING**: [Using command templates can be extremely dangerous](https://github.com/sun-zheng-an/gulp-shell/issues/83). Don't shoot yourself in the foot by ~~passing arguments like `$(rm -rf $HOME)`~~.

#### options.cwd

type: `String`
type: `string`

default: [`process.cwd()`](http://nodejs.org/api/process.html#process_process_cwd)

Sets the current working directory for the command. This can be a [template][] which can be interpolated by some [file][] info (e.g. `file.path`).

#### options.env

type: `Object`
type: `object`

By default, all the commands will be executed in an environment with all the variables in [`process.env`](http://nodejs.org/api/process.html#process_process_env) and `PATH` prepended by `./node_modules/.bin` (allowing you to run executables in your Node's dependencies).

Expand All @@ -69,48 +69,48 @@ For example, setting it to `{ PATH: process.env.PATH }` will reset the `PATH` if

#### options.shell

type: `String`
type: `string`

default: `/bin/sh` on UNIX, and `cmd.exe` on Windows

Change it to `bash` if you like.

#### options.quiet

type: `Boolean`
type: `boolean`

default: `false`

By default, it will print the command output.

#### options.verbose

type: `Boolean`
type: `boolean`

default: `false`

Set to `true` to print the command(s) to stdout as they are executed

#### options.ignoreErrors

type: `Boolean`
type: `boolean`

default: `false`

By default, it will emit an `error` event when the command finishes unsuccessfully.

#### options.errorMessage

type: `String`
type: `string`

default: ``Command `<%= command %>` failed with exit code <%= error.code %>``
default: `` Command `<%= command %>` failed with exit code <%= error.code %> ``

You can add a custom error message for when the command fails.
This can be a [template][] which can be interpolated with the current `command`, some [file][] info (e.g. `file.path`) and some error info (e.g. `error.code`).

#### options.templateData

type: `Object`
type: `object`

The data that can be accessed in [template][].

Expand Down
29 changes: 0 additions & 29 deletions gulpfile.js

This file was deleted.

29 changes: 29 additions & 0 deletions gulpfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import gulp from 'gulp'
import shell from './index'

const files = ['*.ts', 'test/*.js']

gulp.task('build', shell.task('tsc'))

gulp.task('test', shell.task('mocha'))

gulp.task('coverage', shell.task('nyc mocha'))

gulp.task(
'coveralls',
gulp.series(
'coverage',
shell.task('nyc report --reporter=text-lcov | coveralls')
)
)

gulp.task('format', shell.task('prettier --write ' + files.join(' ')))

gulp.task('default', gulp.series('build', 'coverage', 'format'))

gulp.task(
'watch',
gulp.series('default', () => {
gulp.watch(files, gulp.task('default'))
})
)
117 changes: 0 additions & 117 deletions index.js

This file was deleted.

Loading

0 comments on commit 069bb0c

Please sign in to comment.