#!/bin/sh global dart_files := $[find lib web -name "*.dart] test -z $dart_files && exit 0 global unformatted := $[dartfmt -n $dart_files] test -z $unformatted && exit 0 # Some files are not dartfmt'd. Print message and fail. echo >&2 "dart files must be formatted with dartfmt. Please run:> !2 "dart files must be formatted with dartfmt. Please run:" for fn in [$unformatted] { echo >&2 " dartfmt -w $PWD/$fn> !2 " dartfmt -w $PWD/$fn" } exit 1 (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dart_files) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(find)} {(lib)} {(web)} {(-name)} {(DQ ("*.dart"))})] ) left_token: spids: [5 17] ) } spids: [4] ) ] spids: [4] ) (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$dart_files"))} {(Lit_Other "]")}) (C {(exit)} {(0)}) ] op_id: Op_DAmp ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:unformatted) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(dartfmt)} {(-n)} {($ VSub_Name "$dart_files")})] ) left_token: spids: [37 43] ) } spids: [36] ) ] spids: [36] ) (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$unformatted"))} {(Lit_Other "]")}) (C {(exit)} {(0)}) ] op_id: Op_DAmp ) (SimpleCommand words: [{(echo)} {(DQ ("dart files must be formatted with dartfmt. Please run:"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[67])] ) (ForEach iter_name: fn iter_words: [{($ VSub_Name "$unformatted")}] do_arg_iter: False body: (DoGroup children: [ (SimpleCommand words: [{(echo)} {(DQ (" dartfmt -w ") ($ VSub_Name "$PWD") (/) ($ VSub_Name "$fn"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[88])] ) ] spids: [83 98] ) spids: [79 81] ) (C {(exit)} {(1)}) ] )