Skip to content

Commit

Permalink
Add yarn style and check style in CI
Browse files Browse the repository at this point in the history
Two changes:

1. If you run `yarn style` then it will run prettier and write changes
to source files.

2. If you run `yarn test:ci` then it will run prettier with
the `--list-different` command which will just fail if there are
differences.

Fixes #152
  • Loading branch information
backus authored and devonzuegel committed Jul 15, 2017
1 parent cf90705 commit 4d7fdf9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -6,6 +6,8 @@
"build": "node tasks build",
"build:prod": "node tasks build:prod",
"lint": "node tasks lint",
"style": "node tasks style",
"pretest": "node tasks lint",
"test": "node tasks test",
"test:ci": "node tasks test:ci",
"test:watch": "node tasks test:watch",
Expand Down
18 changes: 18 additions & 0 deletions tasks/index.js
Expand Up @@ -11,13 +11,30 @@ const lint = () => {
runCmd("tslint -c tslint.json 'src/**/*.{ts,tsx}'")
}

const runPrettier = (...flags) => {
runCmd(
[
'prettier',
'--print-width 85',
'--trailing-comma es5',
'--no-bracket-spacing',
'--no-semi',
'--single-quote',
...flags,
"'!(node_modules|build|coverage|dist)/**/*.{js,ts,tsx}'",
].join(' ')
)
}

const tasks = {
/****************************************************************************/
/** Linting *****************************************************************/
/****************************************************************************/

lint,

style: () => runPrettier('--write'),

/****************************************************************************/
/** Development *************************************************************/
/****************************************************************************/
Expand Down Expand Up @@ -57,6 +74,7 @@ const tasks = {

test: () => {
lint()
runPrettier('--list-different')
runCmd('NODE_ENV=test jest --coverage')
runCmd('NODE_ENV=test nightwatch --config test/nightwatch.js')
},
Expand Down

0 comments on commit 4d7fdf9

Please sign in to comment.