Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
930baeb9
Commit
930baeb9
authored
May 26, 2018
by
Tim Zallmann
Committed by
Lukas Eipert
Jun 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added possibility to run prettier against one specific directory to make our conversion easier
parent
5f3a219e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
doc/development/new_fe_guide/style/prettier.md
doc/development/new_fe_guide/style/prettier.md
+14
-0
scripts/frontend/prettier.js
scripts/frontend/prettier.js
+9
-3
No files found.
doc/development/new_fe_guide/style/prettier.md
View file @
930baeb9
...
...
@@ -43,3 +43,17 @@ yarn prettier-all-save
Formats all files in the repository with Prettier. (This should only be used to test global rule updates otherwise you would end up with huge MR's).
The source of these Yarn scripts can be found in
`/scripts/frontend/prettier.js`
.
### Scripts during Conversion period
```
node ./scripts/frontend/prettier.js check ./vendor/
```
This will go over all files in a specific folder check it.
```
node ./scripts/frontend/prettier.js save ./vendor/
```
This will go over all files in a specific folder and save it.
scripts/frontend/prettier.js
View file @
930baeb9
...
...
@@ -9,6 +9,8 @@ const getStagedFiles = require('./frontend_script_utils').getStagedFiles;
const
mode
=
process
.
argv
[
2
]
||
'
check
'
;
const
shouldSave
=
mode
===
'
save
'
||
mode
===
'
save-all
'
;
const
allFiles
=
mode
===
'
check-all
'
||
mode
===
'
save-all
'
;
let
dirPath
=
process
.
argv
[
3
]
||
''
;
if
(
dirPath
.
charAt
(
dirPath
.
length
-
1
)
!==
'
/
'
)
dirPath
+=
'
/
'
;
const
config
=
{
patterns
:
[
'
**/*.js
'
,
'
**/*.vue
'
,
'
**/*.scss
'
],
...
...
@@ -39,9 +41,9 @@ prettierIgnore.add(
const
availableExtensions
=
Object
.
keys
(
config
.
parsers
);
console
.
log
(
`Loading
${
allFiles
?
'
All
'
:
'
S
tag
ed
'
}
Files ...`
);
console
.
log
(
`Loading
${
allFiles
?
'
All
'
:
'
S
elect
ed
'
}
Files ...`
);
const
stagedFiles
=
allFiles
?
null
:
getStagedFiles
(
availableExtensions
.
map
(
ext
=>
`*.
${
ext
}
`
));
const
stagedFiles
=
allFiles
||
dirPath
?
null
:
getStagedFiles
(
availableExtensions
.
map
(
ext
=>
`*.
${
ext
}
`
));
if
(
stagedFiles
)
{
if
(
!
stagedFiles
.
length
||
(
stagedFiles
.
length
===
1
&&
!
stagedFiles
[
0
]))
{
...
...
@@ -60,6 +62,11 @@ if (allFiles) {
const
patterns
=
config
.
patterns
;
const
globPattern
=
patterns
.
length
>
1
?
`{
${
patterns
.
join
(
'
,
'
)}
}`
:
`
${
patterns
.
join
(
'
,
'
)}
`
;
files
=
glob
.
sync
(
globPattern
,
{
ignore
}).
filter
(
f
=>
allFiles
||
stagedFiles
.
includes
(
f
));
}
else
if
(
dirPath
)
{
const
ignore
=
config
.
ignore
;
const
patterns
=
config
.
patterns
.
map
((
item
)
=>
{
return
dirPath
+
item
;});
const
globPattern
=
patterns
.
length
>
1
?
`{
${
patterns
.
join
(
'
,
'
)}
}`
:
`
${
patterns
.
join
(
'
,
'
)}
`
;
files
=
glob
.
sync
(
globPattern
,
{
ignore
});
}
else
{
files
=
stagedFiles
.
filter
(
f
=>
availableExtensions
.
includes
(
f
.
split
(
'
.
'
).
pop
()));
}
...
...
@@ -73,7 +80,6 @@ if (!files.length) {
console
.
log
(
`
${
shouldSave
?
'
Updating
'
:
'
Checking
'
}
${
files
.
length
}
file(s)`
);
files
.
forEach
(
file
=>
{
try
{
prettier
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment