Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(support-info): add options field #3433

Merged
merged 17 commits into from Dec 31, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -21,6 +21,7 @@
"cjk-regex": "1.0.2",
"cosmiconfig": "3.1.0",
"dashify": "0.2.2",
"dedent": "0.7.0",
"diff": "3.2.0",
"editorconfig": "0.14.2",
"editorconfig-to-prettier": "0.0.5",
Expand Down Expand Up @@ -77,6 +78,7 @@
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-replace": "1.2.1",
"shelljs": "0.7.8",
"snapshot-diff": "0.2.2",
"strip-ansi": "4.0.0",
"sw-toolbox": "3.6.0",
"uglify-es": "3.0.28",
Expand Down
16 changes: 6 additions & 10 deletions src/cli-constant.js
@@ -1,6 +1,7 @@
"use strict";

const camelCase = require("camelcase");
const dedent = require("dedent");

const CATEGORY_CONFIG = "Config";
const CATEGORY_EDITOR = "Editor";
Expand Down Expand Up @@ -386,17 +387,12 @@ const minimistOptions = {
)
};

const usageSummary = `
Usage: prettier [options] [file/glob ...]
const usageSummary = dedent(`
Copy link
Member

@lydell lydell Dec 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn’t dedent supposed to be used as a template tag?

Usage: prettier [options] [file/glob ...]

By default, output is written to stdout.
Stdin is read if it is piped to Prettier and no files are given.
`.trim();

function dedent(str) {
const spaces = str.match(/\n^( +)/m)[1].length;
return str.replace(new RegExp(`^ {${spaces}}`, "gm"), "").trim();
}
By default, output is written to stdout.
Stdin is read if it is piped to Prettier and no files are given.
`);

function normalizeDetailedOptions(rawDetailedOptions) {
const names = Object.keys(rawDetailedOptions).sort();
Expand Down
4 changes: 2 additions & 2 deletions src/options.js
Expand Up @@ -4,7 +4,7 @@ const path = require("path");

const validate = require("jest-validate").validate;
const deprecatedConfig = require("./deprecated");
const supportTable = require("./support").supportTable;
const supportLanguages = require("./support").supportLanguages;

const defaults = {
cursorOffset: -1,
Expand Down Expand Up @@ -43,7 +43,7 @@ function normalize(options) {
const extension = path.extname(filepath);
const filename = path.basename(filepath).toLowerCase();

const language = supportTable.find(
const language = supportLanguages.find(
language =>
typeof language.since === "string" &&
(language.extensions.indexOf(extension) > -1 ||
Expand Down