Commit Graph

18 Commits (c4e546351402c6d887e686215e22bf0ddda223c6)

Author SHA1 Message Date
Ika c4e5463514 refactor(cli): separate files and make it pure as possible (#2730)
* refactor(bin): resolveConfig

* refactor(bin): getOptionsForFile

* refactor(bin): remove `mapSeries`

* refactor: move content from bin to src/cli

* refactor: wrap content with function

* refactor: move constants to another file

* refactor: move utils to another file

* refactor: move functions

* refactor: extract functions

* refactor: remove unnecessary variable

* refactor: move `src/cli` to `src` with prefix `cli`

* refactor: use template literal

* refactor: remove unnecessary variable

* refactor: extract `listDifferent`

* refactor: extract `format`

* refactor: change error message `Invalid configuration:`

* refactor: bind args with argv

* refactor: extract `getOptionsForFile`

* refactor: extract `formatStdin`

* refactor: extract `eachFilename`

* refactor: extract `formatFiles`

* refactor: remove unnecessary export

* refactor: use `globby.sync()`

* refactor: add `runPrettier.sync()` helper

* refactor: fix linting

* refactor: mock `process.argv`

* chore: use `--forceExit` to avoid process hanging

* refactor: mock `get-stream`

* refactor: remove unnecessary stuff

* refactor: fix linting

* refactor: wrap `run` with `try..catch.finally`

* refactor: restore `process.exitCode` after testing
2017-09-03 19:21:06 +10:00
Ika 088aa71b07 feat(resolve-config): add `.sync()` method (#2722)
* feat(resolve-config): add `sync` option

* docs(readme): add `sync` option

* fix(clearCache):  always clear both

* chore(deps): switch to 3.0 branch

* feat: replace `sync` option with `.sync()`

* docs(readme): update `.sync()`
2017-09-01 20:17:07 +10:00
Simon Lydell 7c9e589323 Fix CLI option parsing (#2684)
Fixes #2683
2017-08-29 08:16:04 +02:00
Lucas Azzola 1c806f81b2 Rename --resolve-config to --find-config-path (#2453) 2017-07-11 23:57:26 +10:00
Evilebot Tnawi 469059dc20 CLI: Support .ignore files (#2412)
Closes #2294
2017-07-11 23:33:46 +10:00
Lucas Azzola dcccfed366 Implement cosmiconfig for workspace configuration (#2434)
* Implement cosmiconfig

* Add resolveOptions API and extname support

* Add --resolve-config and --config, rename resolveOptions to resolveConfig

* Move color to top-level CLI options

* Fix unknown param warning

* Change from {} to null when no config is found

* Change override API to emulate eslint

* Add test for eslint-style overrides

* Delete overrides from resolveConfig
2017-07-10 22:26:36 +10:00
Joseph Frazier 16bc297572 Fix --debug-print-doc (#2400)
* Add test of --debug-print-doc

See https://github.com/prettier/prettier/issues/2396

* Pass test of --debug-print-doc

See https://github.com/prettier/prettier/issues/2396
2017-07-05 18:25:51 +02:00
Joseph Frazier e82a774568 Make --list-different to work with --stdin (#2393)
* Add test for `prettier --stdin --list-different`

See https://github.com/prettier/prettier/issues/2389

* Pass test for `prettier --stdin --list-different`

This fixes https://github.com/prettier/prettier/issues/2389

* Deduplicate --list-different handling

* Exit-early to reduce nesting in listDifferent()

* Simplify condition in listDifferent()
2017-07-04 14:41:46 -04:00
Evilebot Tnawi a0cadad222 feat(cli): support multiple patterns with ignore pattern (#2356) 2017-07-04 17:55:06 +02:00
Lucas Azzola 21f913cb6e CLI: ignore node_modules with ./**-style glob, fixes #2110 (#2185) 2017-06-18 14:35:42 +10:00
Joseph Frazier aedc6d4269 Add integration test of invalid syntax (#2160) 2017-06-16 09:10:39 +10:00
Joseph Frazier 3bbfa97152 Check exit codes in integration tests (#2148) 2017-06-15 09:56:48 +10:00
Lucas Azzola 364c38de0d Implement custom parser API (#1783)
* feat(api): add custom parser API

* test(api): add integration test for parser resolution

* chore(api): fix build after resolving conflicts

* docs(api): document custom parser API

* docs(api): fix typo

* chore(build): add parse5 to build and support yarn test --prod
2017-06-12 16:51:12 +10:00
Joseph Frazier 552ceb30e8 Allow --debug-check to work with stdin (#2013)
* Allow --debug-check to work with stdin

This makes it easier to quickly test formatting code snippets with e.g.

    pbpaste | prettier --debug-check

Before, the following would happen:

    $ pbpaste | prettier --debug-check
    stdin: TypeError: Invalid data, chunk must be a string or buffer, not undefined
        at WriteStream.Socket.write (net.js:693:11)
        at writeOutput (/Users/josephfrazier/workspace/prettier/bin/prettier.js:375:18)
        at getStdin.then.input (/Users/josephfrazier/workspace/prettier/bin/prettier.js:275:7)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:169:7)
    $

Now, it looks like this:

    $ pbpaste | prettier --debug-check
    (stdin)
    $

* Test that --debug-check still prints filenames

See https://github.com/prettier/prettier/pull/2013#discussion_r120499306
2017-06-06 16:10:24 -07:00
Philipp Spieß d679f235ed Also infer parser when using `--list-different` (#1997)
* Also infer parser when using `--list-different`

* Add integration tests for parser inference
2017-06-06 08:24:56 -07:00
Joseph Frazier 451f4aaad5 Add regression test for --debug-check (#1917)
See https://github.com/prettier/prettier/pull/1916
2017-06-02 15:30:39 -07:00
Joseph Frazier f6dabc0d27 Add regression test for CLI shebang preservation (#1901)
Following up on https://github.com/prettier/prettier/pull/1899
2017-06-02 13:42:44 -07:00
Michał Pierzchała 7a0df958dc Ignore node_modules when running prettier from CLI (#1683)
* Ignore node_modules by default

* Add integration test suite for --with-node-modules CLI arg

* Refactor tests to snapshots

* Disable eslint for purposely faulty files

* Fix node 4

* Fix prettier

* Gitignore only top-level node_modules
2017-05-23 14:19:04 -07:00