This repository has been archived by the owner on Feb 17, 2021. It is now read-only.
forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a Prettier task * Add docs for setting up Prettier in an app * Update Prettier readme * Update Prettier docs * Don't write files with Prettier by default * Upgrade Prettier * Bump minor version 7.3.0
- Loading branch information
1 parent
08b42ce
commit 3b2bbf4
Showing
5 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Prettier | ||
|
||
## Adding Prettier to an App | ||
|
||
Prettier is available in @trunkclub/build version 7.3 and above. | ||
|
||
### Usage | ||
|
||
```bash | ||
yarn tcweb-build prettier -- --write "{src,spec}/**/*.{js,jsx,es6}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var spawn = require('cross-spawn'); | ||
|
||
// First two args will always be: | ||
// - node | ||
// - path/to/prettier.js (this file) | ||
var argsIndex = process.argv[2] === '--' ? 3 : 2; | ||
var args = process.argv.slice(argsIndex); | ||
|
||
var result = spawn.sync( | ||
path.resolve(__dirname, '../node_modules/.bin/prettier'), | ||
[ | ||
'--single-quote', | ||
'--no-semi', | ||
'--trailing-comma', 'all', | ||
].concat(args), | ||
{ stdio: 'inherit' } | ||
); | ||
|
||
if (result.signal) { | ||
if (result.signal === 'SIGKILL') { | ||
console.log( | ||
'The prettier task failed because the process exited too early. ' + | ||
'This probably means the system ran out of memory or someone called ' + | ||
'`kill -9` on the process.' | ||
); | ||
} else if (result.signal === 'SIGTERM') { | ||
console.log( | ||
'The prettier task failed because the process exited too early. ' + | ||
'Someone might have called `kill` or `killall`, or the system could ' + | ||
'be shutting down.' | ||
); | ||
} | ||
process.exit(1); | ||
} | ||
|
||
process.exit(result.status); |