Skip to content

Commit

Permalink
Run prettier on output in build dirs (#5858)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and mjesun committed Mar 22, 2018
1 parent dab57e3 commit 69c11a0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@

### Chore & Maintenance

* `[#5858]` Run Prettier on compiled output
([#5858](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
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ exports[`works with async failures 1`] = `
+ \\"foo\\": \\"bar\\",
}
at packages/expect/build/index.js:104:76
at packages/expect/build/index.js:160:61
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`cannot test with no implementation 1`] = `
4 | test('test, no implementation');
5 |
at packages/jest-jasmine2/build/jasmine/Env.js:390:15
at packages/jest-jasmine2/build/jasmine/Env.js:405:15
at __tests__/only-constructs.test.js:3:5
"
Expand All @@ -59,7 +59,7 @@ exports[`cannot test with no implementation with expand arg 1`] = `
4 | test('test, no implementation');
5 |
at packages/jest-jasmine2/build/jasmine/Env.js:390:15
at packages/jest-jasmine2/build/jasmine/Env.js:405:15
at __tests__/only-constructs.test.js:3:5
"
Expand Down
6 changes: 5 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,8 @@ const transformOptions = JSON.parse(
fs.readFileSync(path.resolve(__dirname, '..', '.babelrc'), 'utf8')
);
transformOptions.babelrc = false;
const prettierConfig = prettier.resolveConfig.sync(__filename);
prettierConfig.trailingComma = 'none';

const adjustToTerminalWidth = str => {
const columns = process.stdout.columns || 80;
Expand Down Expand Up @@ -161,7 +164,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

0 comments on commit 69c11a0

Please sign in to comment.