forked from fbeline/design-patterns-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.js
More file actions
35 lines (33 loc) · 931 Bytes
/
format.js
File metadata and controls
35 lines (33 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const jsBeautify = require('js-beautify')['js_beautify'];
const fs = require('fs');
const glob = require('glob');
const options = {
indent_size: 2,
indent_char: ' ',
indent_with_tabs: false,
eol: '\n',
end_with_newline: true,
indent_level: 0,
preserve_newlines: true,
max_preserve_newlines: 2,
space_in_paren: false,
space_in_empty_paren: false,
jslint_happy: false,
space_after_anon_function: false,
brace_style: 'collapse',
break_chained_methods: false,
keep_array_indentation: false,
unescape_strings: false,
wrap_line_length: 0,
e4x: false,
comma_first: false,
operator_position: 'before-newline'
};
glob('**/*(src|test)/**/*.js', { absolute: true }, (er, files) => {
files.forEach(file => {
console.log(`js-beautify ${file}`);
const data = fs.readFileSync(file, 'utf8');
const nextData = jsBeautify(data, options);
fs.writeFileSync(file, nextData, 'utf8');
});
});