git-format-staged 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/git-format-staged +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ For detailed information run:
|
|
|
61
61
|
The command expects a shell command to run a formatter, and one or more file
|
|
62
62
|
patterns to identify which files should be formatted. For example:
|
|
63
63
|
|
|
64
|
-
$ git-format-staged --formatter 'prettier --stdin
|
|
64
|
+
$ git-format-staged --formatter 'prettier --stdin-filepath "{}"' 'src/*.js'
|
|
65
65
|
|
|
66
66
|
That will format all files under `src/` and its subdirectories using
|
|
67
67
|
`prettier`. The file pattern is tested against staged files using Python's
|
|
@@ -75,7 +75,7 @@ content to `stdout`.
|
|
|
75
75
|
|
|
76
76
|
Files can be excluded by prefixing a pattern with `!`. For example:
|
|
77
77
|
|
|
78
|
-
$ git-format-staged --formatter 'prettier --stdin' '*.js' '!flow-typed/*'
|
|
78
|
+
$ git-format-staged --formatter 'prettier --stdin-filepath "{}"' '*.js' '!flow-typed/*'
|
|
79
79
|
|
|
80
80
|
Patterns are evaluated from left-to-right: if a file matches multiple patterns
|
|
81
81
|
the right-most pattern determines whether the file is included or excluded.
|
|
@@ -89,7 +89,7 @@ with the path of the file that is being formatted. This is useful if your
|
|
|
89
89
|
formatter needs to know the file extension to determine how to format or to
|
|
90
90
|
lint each file. For example:
|
|
91
91
|
|
|
92
|
-
$ git-format-staged -f 'prettier --stdin
|
|
92
|
+
$ git-format-staged -f 'prettier --stdin-filepath "{}"' '*.js' '*.css'
|
|
93
93
|
|
|
94
94
|
Do not attempt to read or write to `{}` in your formatter command! The
|
|
95
95
|
placeholder exists only for referencing the file name and path.
|
package/git-format-staged
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# ignoring unstaged changes.
|
|
8
8
|
#
|
|
9
9
|
# Usage: git-format-staged [OPTION]... [FILE]...
|
|
10
|
-
# Example: git-format-staged --formatter 'prettier --stdin' '*.js'
|
|
10
|
+
# Example: git-format-staged --formatter 'prettier --stdin-filepath "{}"' '*.js'
|
|
11
11
|
#
|
|
12
12
|
# Tested with Python 3.6 and Python 2.7.
|
|
13
13
|
#
|
|
@@ -22,8 +22,8 @@ import re
|
|
|
22
22
|
import subprocess
|
|
23
23
|
import sys
|
|
24
24
|
|
|
25
|
-
# The string 2.1.
|
|
26
|
-
VERSION = '2.1.
|
|
25
|
+
# The string 2.1.3 is replaced during the publish process.
|
|
26
|
+
VERSION = '2.1.3'
|
|
27
27
|
PROG = sys.argv[0]
|
|
28
28
|
|
|
29
29
|
def info(msg):
|
|
@@ -231,12 +231,12 @@ class CustomArgumentParser(argparse.ArgumentParser):
|
|
|
231
231
|
if __name__ == '__main__':
|
|
232
232
|
parser = CustomArgumentParser(
|
|
233
233
|
description='Transform staged files using a formatting command that accepts content via stdin and produces a result via stdout.',
|
|
234
|
-
epilog='Example: %(prog)s --formatter "prettier --stdin" "src/*.js" "test/*.js"'
|
|
234
|
+
epilog='Example: %(prog)s --formatter "prettier --stdin-filepath \'{}\'" "src/*.js" "test/*.js"'
|
|
235
235
|
)
|
|
236
236
|
parser.add_argument(
|
|
237
237
|
'--formatter', '-f',
|
|
238
238
|
required=True,
|
|
239
|
-
help='Shell command to format files, will run once per file. Occurrences of the placeholder `{}` will be replaced with a path to the file being formatted. (Example: "prettier --stdin
|
|
239
|
+
help='Shell command to format files, will run once per file. Occurrences of the placeholder `{}` will be replaced with a path to the file being formatted. (Example: "prettier --stdin-filepath \'{}\'")'
|
|
240
240
|
)
|
|
241
241
|
parser.add_argument(
|
|
242
242
|
'--no-update-working-tree',
|
package/package.json
CHANGED