11const fs = require ( 'fs/promises' ) ;
22const path = require ( 'path' ) ;
33const jsdom = require ( 'jsdom' ) ;
4- const { js : beautifyJs , css : beautifyCss } = require ( 'js-beautify' ) ;
5-
6- const BEAUTIFIER_OPTIONS = {
7- indent_size : '4' ,
8- indent_char : ' ' ,
9- max_preserve_newlines : '1' ,
10- preserve_newlines : true ,
11- keep_array_indentation : true ,
12- break_chained_methods : true ,
13- indent_scripts : 'normal' ,
14- brace_style : 'collapse' ,
15- space_before_conditional : true ,
16- unescape_strings : false ,
17- jslint_happy : true ,
18- end_with_newline : false ,
19- wrap_line_length : '110' ,
20- indent_inner_html : true ,
21- comma_first : false ,
22- e4x : false ,
23- indent_empty_lines : false ,
24- } ;
254
265const PATH = path . resolve ( __dirname ) ;
276
@@ -48,23 +27,21 @@ fetch(GAME)
4827 return files ;
4928 } )
5029 . then ( async ( { js, css } ) => ( {
51- js : await fetch ( `${ GAME } ${ js } ` )
52- . then ( res => res . text ( ) )
53- . then ( js => beautifyJs ( js , BEAUTIFIER_OPTIONS ) ) ,
54- css : await fetch ( `${ GAME } ${ css } ` )
55- . then ( res => res . text ( ) )
56- . then ( css => beautifyCss ( css , BEAUTIFIER_OPTIONS ) ) ,
30+ js : await fetch ( `${ GAME } ${ js } ` ) . then ( res => res . text ( ) ) ,
31+ css : await fetch ( `${ GAME } ${ css } ` ) . then ( res => res . text ( ) ) ,
5732 jsPath : js ,
5833 cssPath : css ,
5934 } ) )
60- . then ( ( { js, css, jsPath, cssPath } ) => Promise . all ( [
61- fs
62- . writeFile ( path . resolve ( PATH , 'application.js' + suffix ) , js )
63- . then ( ( ) => jsPath ) ,
64- fs
65- . writeFile ( path . resolve ( PATH , 'application.css' + suffix ) , css )
66- . then ( ( ) => cssPath ) ,
67- ] ) )
35+ . then ( ( { js, css, jsPath, cssPath } ) =>
36+ Promise . all ( [
37+ fs
38+ . writeFile ( path . resolve ( PATH , `application${ suffix } .js` ) , js )
39+ . then ( ( ) => jsPath ) ,
40+ fs
41+ . writeFile ( path . resolve ( PATH , `application${ suffix } .css` ) , css )
42+ . then ( ( ) => cssPath ) ,
43+ ] )
44+ )
6845 . then ( ( [ jsPath , cssPath ] ) =>
6946 fs
7047 . readFile ( path . resolve ( PATH , 'README.md' ) )
@@ -77,12 +54,6 @@ fetch(GAME)
7754 / < ! - - \s * a u t o m a t e d \s - - > ( .| \n ) * ?< ! - - \s * \/ a u t o m a t e d \s * - - > / ,
7855 `
7956<!-- automated -->
80- ## Beautify options
81- Tool: [js-beautify](https://github.com/beautify-web/js-beautify)
82- \`\`\`json
83- ${ JSON . stringify ( BEAUTIFIER_OPTIONS , null , 4 ) }
84- \`\`\`
85-
8657## JS
8758| Attribute | Value |
8859| --------- | ----- |
@@ -96,6 +67,11 @@ ${JSON.stringify(BEAUTIFIER_OPTIONS, null, 4)}
9667| File | [${ cssPath . replace ( / ^ \/ a s s e t s \/ / , '' ) } ](${ GAME } ${ cssPath } ) |
9768| Server | ${ GAME } |
9869| Time | ${ timestamp } |
70+
71+ ## Pretty-print
72+ Tool: [prettier](https://prettier.io)
73+ Options: [.prettierrc.json](./.prettierrc.json)
74+
9975<!-- /automated -->
10076` . trim ( )
10177 )
0 commit comments