@@ -4,6 +4,7 @@ import * as fs from "fs";
44import * as yaml from "js-yaml" ;
55import * as flrPathMan from "./folder-manager" ;
66import * as utils from "./utils" ;
7+ const os = require ( "os" ) ;
78
89export class ResourceGenerator {
910 static namePool : string [ ] = new Array ( ) ;
@@ -161,7 +162,32 @@ export class ResourceGenerator {
161162 content += textBlock ;
162163
163164 fs . writeFileSync ( file , content ) ;
164- utils . execute ( `dartfmt -l 100 -w ${ file } ` ) ;
165+
166+ /// read line length settings for dart and format
167+ let platform = process . platform ;
168+ var settingFilePath = "" ;
169+ let settingFile = "Code/User/settings.json" ;
170+ /// https://vscode.readthedocs.io/en/latest/getstarted/settings/
171+ if ( platform === "win32" && process . env . APPDATA !== undefined ) {
172+ // windows
173+ settingFilePath = path . join ( process . env . APPDATA , settingFile ) ;
174+ } else if ( platform === "darwin" ) {
175+ // macOS
176+ settingFilePath = `${ os . homedir ( ) } /Library/Application Support/${ settingFile } ` ;
177+ } else {
178+ // linux
179+ settingFilePath = `${ os . homedir ( ) } /.config/${ settingFile } ` ;
180+ }
181+
182+ let settings = fs . readFileSync ( settingFilePath , "utf8" ) ;
183+ let json = JSON . parse ( settings ) ;
184+ let ll = json [ "dart.lineLength" ] ;
185+ var lineLength = 80 ;
186+ if ( ll !== null && ll !== undefined ) {
187+ lineLength = parseInt ( ll ) ;
188+ }
189+
190+ utils . execute ( `flutter format -l ${ lineLength } ${ file } ` ) ;
165191 } catch ( e ) {
166192 console . log ( e ) ;
167193 }
0 commit comments