Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #62 from pawelgalazka/v4.1
Browse files Browse the repository at this point in the history
v4.1
  • Loading branch information
Paweł Gałązka authored Sep 16, 2017
2 parents 9f647b1 + 50e0f1c commit 8731a82
Show file tree
Hide file tree
Showing 15 changed files with 1,621 additions and 1,048 deletions.
10 changes: 10 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[ignore]

[include]

[libs]

[lints]

[options]
module.ignore_non_literal_requires=true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
*.swp
.DS_Store
npm-debug.log
/coverage
/lib
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.travis.yml
node_modules
/test
/src
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Minimalistic building tool
- [Why runjs ?](#why-runjs-)
- [API](#api)
- [run](#runcmd-options)
- [options](#optionsthis-name)
- [option](#optionthis-name)
- [Transpilers](#transpilers)
- [Babel](#babel)
Expand Down Expand Up @@ -141,7 +142,6 @@ run given command as a child process and log the call in the output.
async: ... // run command asynchronously (true/false), false by default
stdio: ... // 'inherit' (default), 'pipe' or 'ignore'
env: ... // environment key-value pairs (Object)
log: ... // log command to console (true/false), true by default
timeout: ...
}
```
Expand All @@ -161,13 +161,44 @@ run('http-server .', {async: true, stdio: 'pipe'}).then((output) => {
```

For `stdio: 'pipe'` outputs are returned but not forwarded to the parent process thus
not printed out to the terminal. For `stdio: 'inherit'` (default) outputs are passed
not printed out to the terminal.

For `stdio: 'inherit'` (default) outputs are passed
to the terminal, but `run` function will resolve (async) / return (sync)
`null`.

For `stdio: 'ignore'` nothing will be returned or printed


#### options(this)

A helper which returns an object with options which were given through dash params of command
line script.

Example:

```bash
$ run lint --fix
```

```js
export function lint (path = '.') {
options(this).fix ? run(`eslint ${path} --fix`) : run(`eslint ${path}`)
}
```

Implementation of it is really simple:

```js
function options (thisObj) {
return (thisObj && thisObj.options) || {}
}
```

#### option(this, name)

> This helper is deprecated, use `options` instead
A helper which returns value for an option if given through dash param of command
line script.

Expand Down Expand Up @@ -392,7 +423,6 @@ without any arguments:
Processing runfile.js...

Available tasks:

echo
testapi

Expand All @@ -413,9 +443,7 @@ buildjs.help = 'Compile JavaScript files'
Processing runfile.js...

Available tasks:

buildjs [arg1 arg2]
Compile JavaScript files
buildjs [arg1 arg2] - Compile JavaScript files

When running task with `--help` option, only help for that task will be displayed:

Expand Down
88 changes: 0 additions & 88 deletions lib/index.js

This file was deleted.

58 changes: 47 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "runjs",
"version": "4.0.1",
"version": "4.1.0",
"description": "Minimalistic building tool",
"keywords": [
"build",
Expand All @@ -13,9 +13,13 @@
"run": "bin/run.js"
},
"scripts": {
"lint": "eslint lib/ bin/ test/*.test.js",
"test": "yarn run test:fast && yarn run test:e2e",
"test:fast": "yarn run lint && jest",
"lint": "eslint src/ bin/ test/*.test.js",
"flow": "flow",
"build": "babel src/ --out-dir lib/",
"test": "yarn run lint && yarn run flow -- check && yarn run test:coverage && yarn run build && yarn run test:e2e",
"test:coverage": "jest --coverage",
"test:unit": "jest",
"test:watch": "jest --watch",
"test:e2e": "bash ./test/e2e.test.sh",
"clean": "rm -rf node_modules && yarn run clean:sandbox",
"clean:sandbox": "rm -rf test/babel-sandbox/node_modules && rm -rf test/typescript-sandbox/node_modules"
Expand All @@ -34,19 +38,51 @@
},
"homepage": "https://github.com/pawelgalazka/runjs#readme",
"dependencies": {
"chalk": "1.1.3",
"get-parameter-names": "0.3.0"
"chalk": "2.1.0",
"get-parameter-names": "0.3.0",
"lodash.padend": "4.6.1"
},
"devDependencies": {
"eslint": "3.6.1",
"eslint-config-standard": "6.2.0",
"eslint-plugin-promise": "2.0.1",
"eslint-plugin-standard": "2.0.1",
"jest": "16.0.2"
"babel-cli": "6.26.0",
"babel-eslint": "7.2.3",
"babel-preset-flow": "6.23.0",
"eslint": "4.5.0",
"eslint-config-standard": "10.2.1",
"eslint-plugin-flowtype": "2.35.1",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-node": "5.1.1",
"eslint-plugin-promise": "3.5.0",
"eslint-plugin-standard": "3.0.1",
"flow-bin": "0.54.0",
"jest": "20.0.4"
},
"babel": {
"presets": [
"flow"
]
},
"eslintConfig": {
"parser": "babel-eslint",
"plugins": [
"flowtype"
],
"extends": [
"eslint-config-standard"
]
},
"jest": {
"testEnvironment": "node",
"collectCoverageFrom": [
"src/**/*.js",
"bin/**/*.js"
],
"coverageReporters": [
"text"
],
"coverageThreshold": {
"global": {
"lines": 70
}
}
}
}
27 changes: 14 additions & 13 deletions lib/common.js → src/common.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
// @flow
const chalk = require('chalk')

// Needed to use ES5 inheritance, because of issues with Error subclassing for Babel
function RunJSError (message) {
function RunJSError (message: string) {
this.name = 'RunJSError'
this.message = message && message.split('\n')[0] // assign only first line
}
RunJSError.prototype = Object.create(Error.prototype)
RunJSError.prototype.constructor = RunJSError

const logger = {
debug: (...args) => {
console.log(chalk.blue(...args))
},
info: (...args) => {
class Logger {
title (...args: Array<any>) {
console.log(chalk.bold(...args))
},
log: (...args) => {
}
log (...args: Array<any>) {
console.log(...args)
},
warning: (...args) => {
}
warning (...args: Array<any>) {
console.warn(chalk.yellow(...args))
},
error: (...args) => {
}
error (...args: Array<any>) {
console.error(chalk.red(...args))
}
}

const logger = new Logger()

module.exports = {
RunJSError,
logger
logger,
Logger
}
Loading

0 comments on commit 8731a82

Please sign in to comment.