Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Run prettier on output in build dirs
  • Loading branch information
SimenB committed Mar 22, 2018
commit b9911ae8c50cc82691e7b5141574b8d5aae0b23c
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@

### Chore & Maintenance

* `[#3497]` Run Prettier on compiled output
([#3497](https://github.com/facebook/jest/pull/3497))
* `[#5708]` Add fileChange hook for plugins
([#5648](https://github.com/facebook/jest/pull/5708))
([#5708](https://github.com/facebook/jest/pull/5708))
* `[docs]` Add docs on using `jest.mock(...)`
([#5648](https://github.com/facebook/jest/pull/5648))
* `[docs]` Mention Jest Puppeteer Preset
Expand Down
5 changes: 4 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const mkdirp = require('mkdirp');
const babel = require('babel-core');
const chalk = require('chalk');
const micromatch = require('micromatch');
const prettier = require('prettier');
const stringLength = require('string-length');
const getPackages = require('./getPackages');
const browserBuild = require('./browserBuild');
Expand All @@ -46,6 +47,7 @@ const transformOptions = JSON.parse(
fs.readFileSync(path.resolve(__dirname, '..', '.babelrc'), 'utf8')
);
transformOptions.babelrc = false;
const prettierConfig = prettier.resolveConfig.sync(__filename);

const adjustToTerminalWidth = str => {
const columns = process.stdout.columns || 80;
Expand Down Expand Up @@ -161,7 +163,8 @@ function buildFile(file, silent) {
}

const transformed = babel.transformFileSync(file, options).code;
fs.writeFileSync(destPath, transformed);
const prettyCode = prettier.format(transformed, prettierConfig);
fs.writeFileSync(destPath, prettyCode);
silent ||
process.stdout.write(
chalk.green(' \u2022 ') +
Expand Down