1- import { readFileSync , writeFile } from 'fs' ;
1+ import { readFileSync , writeFileSync } from 'fs' ;
22import { extname } from 'path' ;
33import { observable , computed , action , autorun , toJS , spy } from 'mobx' ;
44import range from 'lodash/range' ;
@@ -176,19 +176,25 @@ class Environment {
176176 // art
177177 const artPath = workspace . absolutePath ( obj . art . path ) ;
178178 const chunk = tilesToBuffer ( this . tiles , obj . art . compression ) ;
179- writeFile ( artPath , chunk , ( err , success ) => {
180- if ( err ) return errorMsg ( 'Error Reading Mapping File' , err ) ;
181- } ) ;
179+ try {
180+ writeFileSync ( artPath , chunk ) ;
181+ }
182+ catch ( e ) {
183+ errorMsg ( 'Error Saving Art' , e . message ) ;
184+ }
182185
183186 // palettes
184187 let lineIndex = 0 ;
185188 obj . palettes . forEach ( ( { path, length} ) => {
186189 const chunk = colorsToBuffers ( this . palettes , lineIndex , lineIndex + length ) ;
187190 lineIndex += length ;
188191
189- writeFile ( workspace . absolutePath ( path ) , chunk , ( err , success ) => {
190- err && errorMsg ( 'Error Saving Palette' , err . message ) ;
191- } ) ;
192+ try {
193+ writeFileSync ( workspace . absolutePath ( path ) , chunk ) ;
194+ }
195+ catch ( e ) {
196+ errorMsg ( 'Error Saving Palette' , e . message ) ;
197+ }
192198 } ) ;
193199
194200 // mappings
@@ -198,9 +204,12 @@ class Environment {
198204
199205 const { chunk, frames } = mappingsToBuffer ( this . mappings , obj . mappingDefinition ) ;
200206 const out = isAsm ? stuffToAsm ( frames , obj . mappings . label , true ) : chunk ;
201- writeFile ( mappingPath , out , ( err , success ) => {
202- err && errorMsg ( 'Error Saving Mappings' , err . message ) ;
203- } ) ;
207+ try {
208+ writeFileSync ( mappingPath , out ) ;
209+ }
210+ catch ( e ) {
211+ errorMsg ( 'Error Saving Mappings' , e . message ) ;
212+ }
204213 }
205214
206215 // dplcs
@@ -210,9 +219,12 @@ class Environment {
210219
211220 const { chunk, frames } = DPLCsToBuffer ( this . dplcs , obj . dplcDefinition ) ;
212221 const out = isAsm ? stuffToAsm ( frames , obj . dplcs . label ) : chunk ;
213- writeFile ( dplcPath , out , ( err , success ) => {
214- err && errorMsg ( 'Error Saving DPLCs' , err . message ) ;
215- } ) ;
222+ try {
223+ writeFileSync ( dplcPath , out ) ;
224+ }
225+ catch ( e ) {
226+ errorMsg ( 'Error Saving DPLCs' , e . message ) ;
227+ }
216228 }
217229
218230 } ;
0 commit comments